2
我正在使用名爲jQuery Tokeninput的jquery插件http://loopj.com/jquery-tokeninput/,我遇到了一個邏輯問題。jQuery tokeninput插件+將id傳遞給另一個tokeninput url
var country_id = "";
jQuery("#demo-input-prevent-duplicates").tokenInput(host+"/forms/campaign_location.php?action=country", {
theme: "facebook",
hintText: "Enter a Country...",
placeholder: "Enter a Country...",
preventDuplicates: true,
onAdd: function(item) {
country_id = item.id;
},
onDelete: function(){
hideElements();
},
tokenDelimiter: "|",
});
我在這裏的問題是如何將country_id的值傳遞給下面的代碼的參數。我沒有看到如何在jquery tokeninput文檔中執行此操作。
jQuery("#targ_state").tokenInput(host+"/forms/campaign_location.php?action=stateorprovince&cid="+country_id, {
theme: "facebook",
preventDuplicates: true,
hintText: "Enter a State or Province...",
placeholder: "Enter a State or Province..."
});
如果你看的這部分代碼,我傳遞的是上面生成的「使用onAdd」的COUNTRY_ID。這雖然不起作用。
jQuery("#targ_state").tokenInput(host+"/forms/campaign_location.php?action=stateorprovince&cid="+country_id ....
我該怎麼做那個?你的幫助將不勝感激,當然,獎勵!
謝謝! :-)
此解決方案不起作用 –