I am creating a jquery widget, the concept is similar to a menu bar, it has two buttons, for example, ButtonOne and ButtonTwo.
I have style associated and my html code.
I worked in a hello world widget
// Constructor
_create: function()
{
var my=this.element;
var supe=this;
..............
//first event
my.bind('mouseenter', function (event) {
supe._trigger('activated', event, my);
});
},
I use like
$(function() {
...........
var bar=$("#bar-event").mybar();
//first atempt
bar.click(function() {
alert( "Handler for .click() called." );
});
//second attempt
bar.bind('mybaractivated', function(event, data) {
// handle the event
alert('YES WORKING!!!!!!');
});
});
My first attempt, was noob attempt, click works, but in all area of top div in html. In second attempt have access to my custom event.
Unknown to how to fire the click events of my buttons, for example, i want control the events like...
//
$(function() {
...........
var bar=$("#bar-event").mybar();
bar.clickButtonOne(function() {/*do*/});
//and
bar.clickButtonTwo(function() {/*do*/});
Or
//Maybe
$(function() {
...........
var bar=$("#bar-event").mybar();
bar.bind('clickButtonOne',function(event,data) {/*do*/});
//and
bar.bind('clickButtonTwo',function(event,data) {/*do*/});
But not to do to trigger events within the widget