I created a widget and figured that it can only be called once per element:

$.widget('ui.mywidget', {
    _init: function() {
        alert('hello');
    }
}

$.widget("ui.mywidget", mywidget);


$("#foo").mywidget(); // alerts hello
$("#foo").mywidget(); // doesn't do anything


now I understand this is by design because _init acts like a static
constructor. however, I want to create a widget to add a panel to #foo
each time it's called so:

$("#foo").addpanel();
$("#foo").addpanel();

But that obvioulsy fails.What's the work around or what is a better
design? I don't want to do:
$("#foo").addpanel();
$("#foo").addpanel("add");
$("#foo").addpanel("add");

because that requires an extra () call followed by ("add"), ("add").





-- Aleem

Reply via email to