Expose javascript variable in jQuery plugin while maintaining chainability? -
Expose javascript variable in jQuery plugin while maintaining chainability? -
the problem plugin need expose var chart , maintain chainability. how can accomplish this? first plugin wrote , don't know if chainability of import preserve. thanks.
html piece
<div id="chart1" class="chart"></div> <div id="chart2" class="chart"></div> plugin invocation
$("div").chart(); plugin definition
(function($) { $.fn.chart = function(options) { homecoming this.each() // maintain chainability { // stuff, ajax phone call , then... var chart = new highcharts(options); // expose each chart variable each container (<div>) } }; })(jquery); edit: added clarification chart variable.
first, should read plugins/authoring if havent already. there ideas in there.
second, can seek this:
$.fn.chart = function(options) { if(options=='get_charts') homecoming charts; else { // stuff, ajax phone call , then... var chart = new highcharts(options); } } this called $('#something').charts({}); or $('#something').charts('get_charts');
jquery jquery-plugins
Comments
Post a Comment