0
我想使用AJAX加載一些輸入&選擇顯示後來在頁面上。我正在做這樣的事情。選擇onfocusin做什麼不工作
<input type='product' alt='2'/>
$("input[type='product']").on("focusin", function(){
var product_type_ids = $(this).attr('alt');
$(this).autocomplete({
// ajax load the information here
});
});
<select type='product' alt='2'/>
$("select[type='product']").on("focusin", function(){
var product_type_ids = $(this).attr('alt');
// some codes here
});
的結果是選擇和投入,從頁面呈現的開始存在,但不是元素後出現了確定。有人知道這裏發生了什麼嗎?謝謝!
它似乎運作良好。但是如果我想讓它在沒有focusin事件的情況下自動加載呢? – 2014-11-03 03:47:23
@ChandlerLee我不確定你的意思是...? – Ohgodwhy 2014-11-03 04:02:56
我的意思是如果我使用focusin事件,那麼我需要在ajax加載之前單擊select並追加選擇。有沒有辦法像這樣使用委託加載ajax內容? – 2014-11-03 04:12:50