jQuery plugin with unforseen options -
i want create jquery plugin takes interesting options parameters. here call ideally.
$.bindmultiple('click', { 'selector1': function1, 'selector2': function2 });
the selectors normal jquery selectors (e.g., input[type=checkbox]) , functions functions in javascript called on bound event (click in instance event programmer wants bind of these elements).
what wondering how access of options sent in. have far:
(function( $ ) { $.fn.bindmultiple = function(bindevent, options) { }; }( jquery ));
edit: adeneo found out needed change $.fn.bindmultiple... $.bindmultiple...
if didn't make stupid typo, work:
(function( $ ) { $.fn.bindmultiple = function(bindevent, options) { $.each(options, function(selector, func){ $(selector).on(bindevent, func); }); }; }( jquery ));
Comments
Post a Comment