2013-10-12 3 views
5

काम नहीं कर रहा मैं यह कोशिश:बूटस्ट्रैप Typeahead अपडेटर

$('input[name=recerv_country]').typeahead({ 
    remote : { 
     url: '?country=%QUERY', 
     filter: function(data) { 
      var resultList = data.map(function (item) { 
       return item.name; 
      }); 
      return resultList; 
     } 
    }, 
    updater : function (item) { 
     //item = selected item 
     //do your stuff. 
     alert(item.name); 
     alert('foo'); 
     alert('bar'); 
     //dont forget to return the item to reflect them into input 
     return item; 
    } 
}); 

कुछ नहीं होता, अलर्ट नहीं दिखाई देता है। मैं क्या गलत करता हूँ?

उत्तर

4

ट्विटर बूटस्ट्रैप 3 के साथ टाइपहेड प्लगइन गिरा दिया गया है। बूटस्ट्रैप स्थिरता में https://github.com/twitter/typeahead.js का उपयोग करने की अनुशंसा करता है। आप typeahead.js का उपयोग करते हैं क्योंकि आप रिमोट कॉल का उपयोग करते हैं। Typeahead.js में एक अद्यतनकर्ता फ़ंक्शन नहीं है।

https://github.com/twitter/typeahead.js के कस्टम ईवेंट अनुभाग देखें। typeahead:selected आपकी आवश्यकताओं के अनुरूप हो सकता है।

यह भी देखें: Bootstrap 3 typeahead.js, use similar functions from Bootstrap 2

7
$('input[name=recerv_country]').on('typeahead:selected', function(evt, item) { 
    alert(item.value); 
}); 
संबंधित मुद्दे