Hi,
I've just developed a plugin that mimics the combo box control, albeit
it's a special one. That's being defined as follows:

(function($) {
    $.fn.extend({
        smartList: function(settings) {
            //prepare settings, blah blah blah...

            return this.each(function() {
                //whatever code goes here...
            });
        }
    });
})(jQuery);

You know, to use this plugin, I could easily write the following
JavaScript code:

var $myList = $('myElement').smartList();

No problem so far. Now, I need to define and access some functions
that's specific to the smartList. say, e.g., getSelectedValue,
insertItem, and the like. The problem is that I've got no idea how to
address such a thing in JavaScript. i.e., I need to write things like:

$myList.getSelectedValue();
$myList.insetItem('foo', 'bar');

But this isn't possible, since the $myList variable is a jQuery
object.

So I just defined some functions, say, $.smartList.getSelectedValue
and the like... but in this approach, I've to pass the jQuery object
to this functions as a mandatory parameter and this really sucks.
i.e., I need to get the selected value of $myList this way:

var value = $.smartList.getSelectedValue($myList);

Is there any better approach to address such a thing?

Any help would be highly appreciated,

TIA,
Mehdi

Reply via email to