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

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -