With some help I have written in JQUERY this:
$('id').clickToggle(addMarker, destroyMarker);
where clickToggle is a function which calls addMarker and destroyMarker functions.
This is the clickToggle() function:
$.fn.clickToggle = function(func1, func2) {
var funcs = [func1, func2];
this.data('toggleclicked', 0);
this.click(function() {
var data = $(this).data();
var tc = data.toggleclicked;
$.proxy(funcs[tc], this)();
data.toggleclicked = (tc + 1) % 2;
});
return this;
};
And addMarker() function is
var addMarker = function(){ ....}
I don't have so much xp in JQUERY. What I want to do is to pass a variable inside the addMarker() function. The way my code is written how can I do it?
$.proxy(funcs[tc], this)()->funcs[tc].call(this)addMarker?