I want to fire off an AJAX call when a plugin is created that will retrieve some data and then continue building the plugin control. So given this simplified version:
$.fn.grid = function (options) {
this.each(function () {
var $this = $(this); // Somehow to maintain $this for the callback
buildPluginBasics($this);
$.getJSON("DataPath", { option1:"etc" }, dataReceived);
});
function dataReceived(data, status) {
buildGridRows($theCallingInstance, data);
}
}
You can see I've not got any way of knowing which plugin element I now need to continue building. I basically need a reference to the original $this
to be available in dataReceived
. Can anyone point me in the right direction?