I have created a simple JQuery extension :
(function($) {
$.fn.extend({
GMselect: function(options){
var defaults = {
url: '',
onSelect: function(){},
loadData: function(url){
$.get(url || this.url).done(function(res){
var opts = '';
for (i in res){
opts += '<option value='+res[i].id+'>'+res[i].name + '</option>';
}
me.html(opts);
});
}
};
var options = $.extend(defaults, options);
options.loadData();
$(this).change( options.onSelect );
var me = $(this);
}
});
}(jQuery));
this way I can easly create select elements reading data from remote JSON source like this:
$('#mySelect').GMselect({
url: 'getData'
});
This part is clear, however I would like to know the way to dynamically reload the select, by invoking the method like
$('#mySelect').reload(url)
Any help and comments will be appreciate

