我有一些代碼在頁面中加載城市列表時,我更改國家選擇框。jQuery.when()。然後()不與選擇更改事件
我想在頁面中使用流動的代碼設置默認值,但.then不工作後的jquery。有任何想法嗎?
該國工作完美,但城市沒有加載。
jQuery(window).load(function() {
jQuery(document).ready(function(){
jQuery('#jr_country').val('united-kingdom');
jQuery.when(jQuery('#jr_country').change()).then(jQuery('#jr_city').val('london'));
});
});
嗨非常感謝我不知道我得到如何實現延遲的jQuery('#jr_country')。它正在生成城市選擇,所以我必須先運行jQuery('#jr_city')。val('london') – 2012-07-23 00:02:25
@ open-ecommerce.org後的變化:這裏是一個很好的閱讀:http:/ /joseoncode.com/2011/09/26/a-walkthrough-jquery-deferred-and-promise/ – zerkms 2012-07-23 00:03:01
非常感謝我認爲我有一個問題,我的網頁的邏輯。我會研究你寄給我的鏈接非常感謝 – 2012-07-23 00:19:54