2012-04-18 43 views
1

我目前使用jQuery中的更改函數。只有當我在文本框外單擊時纔會觸發更改事件。所以,當我在文本框中插入文本時,沒有任何事情發生,但是當我失去焦點時文本字段事件觸發。不,我不想點擊文本框之外的點擊事件。change()僅在失去焦點時纔會觸發

這是我的代碼:

jQuery("#customfield_10000").change(function(){ 
      crmAccount = jQuery(this).val(); 
      alert(crmAccount); 
      lijstAccounts = []; 

        jQuery.ajax({ 
         url: "http://localhost/papa/jQuery/development-bundle/demos/autocomplete/searchAccounts.php?jsonp_callback=?", 
         dataType: 'jsonp', 
         jsonp: "jsonp_callback", 
         data: { 
          featureClass: "P", 
          style: "full", 
          maxRows: 12, 
          name_startsWith: jQuery(this).val() 
          }, 
          success: function(data) { 
           jQuery.map(data, function(item) { 
                  lijstAccounts.push(item.label); 
                  jQuery('#customfield_10000').trigger(
                   'setSuggestions', 
                  { result : textext.itemManager().filter(lijstAccounts, query) } 
                  );    
            return { 
             label: item.label, 
             value: item.value  
            } 
           }); 
          } 
         }); 

      }); 
+0

嘗試與您當前密碼並按Enter鍵:-) – 11684 2012-04-18 13:10:22

回答

1

您可以使用KeyUp event

$("#abcd").keyup(function(event) { 
    //code 
}); 
+0

謝謝!固定 – 2012-04-18 13:13:12

+0

Your're welcome .. – 2012-04-18 13:14:38

+0

感謝您的有用編輯@ Tim-cooper – 2012-04-18 14:39:31

4

您應該處理input(非IE)或propertchange(IE-只),或keyup(不會趕上粘貼或拖動&下降)事件。

+0

@qwertymk:澄清 – SLaks 2012-04-18 13:09:45

+0

謝謝!固定 – 2012-04-18 13:13:24