I want to create stand alone component means kind of widget I have some limitation I cannot use jquery widget library. I want to know what is the right way to bind events on component. for example I want to create some sort of button group If I use that button group anywhere in application it should have ability to accepts callback. where ever If I used this component it should work.
HTML
<div id="btn-grp" data-callback="list of callback function here" data-value="selected button value" data-valid="false">
<button id="btn1">Button 1</button>
<button id="btn2">Button 2</button>
<button id="btn3">Button 3</button>
</div>
Javascript would be
$("body").on('click', '.btn-grp', function() {
console.log("hey you clicked on button ....");
forloop(){
invoke callback 1 or 2 or so many
}
});
One way could be I can create plugin for each component can you please share some sort of wrapper function look like for creating components.