Reputation: 655
function rp_marcadesmarcaFarm(valor) {
FM_log(3, "marcadesmarcaFarm called = "+valor);
for (i = 0; i < farmList.length; i++) {
var arr = farmList[i].split("|");
var xy = arr[0].split(",");
var fvillageId = xy2id(parseInt(xy[0]), parseInt(xy[1]));
GM_setValue("farmAtivada_"+suffixLocal+fvillageId, valor);
GM_setValue("farmAtivada_"+suffixLocal+i, valor);
};
reloadFarmTable();
};
function createLinkButton(text, title, jsFunction, value) {
var button = dom.cn("a");
button.href = "javascript:void(0)";
button.innerHTML = text;
button.title = title;
if (jsFunction != null) {
button.addEventListener('click', jsFunction, false);
}
return button;
}
createLinkButton("X", T('CHECKFARM_M'), rp_marcadesmarcaFarm(true));
apparently the last argument (rp_marcadesmarcaFarm(true)) when invoking the createLinkButton is not working. If I change to:
createLinkButton("X", T('CHECKFARM_M'), rp_marcadesmarcaFarm);
it works. So how can I pass the (true) variable to the third argument of createLinkButton?
Upvotes: 0
Views: 802
Reputation: 36120
createLinkButton
is waiting for a function, but rp_marcadesmarcaFarm(true)
calls the function and actually pass the return value.
What you want is an anonymous function that will call rp_marcadesmarcaFarm(true)
and pass that to createLinkButton
createLinkButton("X", T('CHECKFARM_M'), function(){ rp_marcadesmarcaFarm(true); });
Upvotes: 1
Reputation: 40533
createLinkButton("X", T('CHECKFARM_M'), function() {rp_marcadesmarcaFarm(true)});
Upvotes: 5