0
我正在測試用每個元素內的一個簡單超鏈接創建LI元素。 所有LI元素使用jQuery.appendJavaScript事件點擊觸發兩次
然而實時生成 - 1.如果元素爲回調函數(異步)的一部分創建 - 調用jQuery的AJAX後 - 所有工作正常 2 。如果元素是同步創建的 - 一旦點擊就會觸發兩個點擊事件。
下面是三個相關的JavaScript函數?並注意有兩個硬編碼的超鏈接1.標記爲SYNC 2.標記爲A-SYNC。
有什麼想法?
MCRM.Handler.accounts_index = function(){
console.log("MCRM.Handler.accounts_index");
MCRM.Account.all(function(r){
MCRM.Handler.accounts_list(r);
preventDefaultLink();
});
};
MCRM.Handler.accounts_list = function(r){
console.log("MCRM.Handler.accounts_list");
$('#listAccount').append('<li class="arrow"><a href="app/views/accounts/show.html">A-SYNC</a></li>');
for(var i = 0; i < r.length; i ++) {
record = r[i];
$('#listAccount').append('<li class="arrow">' + MCRM.AccountsHelper.account_link(record) + '</li>');
}
};
MCRM.Account.all = function(success_callback2, options){
var accounts;
console.log("MCRM.Account.all");
$('#listAccount').append('<li class="arrow"><a href="app/views/accounts/show.html">SYNC</a></li>');
var soap = "",
url = MCRM.SIEBEL_URL + "/eai_enu/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&UserName=" + MCRM.SIEBEL_USER + "&Password=" + MCRM.SIEBEL_PWD
soap = MCRM.XML_MY_ACCOUNTS;
jQuery.ajax({
type: "post", url: url, contentType: "text/xml", data: soap, dataType: "xml", processData: false,
success: function(doc, status){
console.log("SUCCESS");
var json = jQuery.xml2json(doc);
//var account = json.Body.SiebelAccountQueryByIdResponse.SiebelMessage.ListOfAccountInterface.Account;
MCRM.Account.accounts = json.Body.Siebel_spcAccount_SiebelAccountQueryByExample_Output.ListOfAccountInterface.Account;
success_callback2(MCRM.Account.accounts);
//MCRM.screen.account_detail.setValue(account.Name + "<br>" + account.MainPhoneNumber);
},
});
};