javascript - Call jQuery widget from outside -


i wrote jquery-widget method clear:

(function($) {     $.widget('ccf.mobileheaderautocomplete', {         ...         clear: function () {             this.ulelement.empty();         },         ...     }); })(jquery); 

i sucessfully call method on input element:

$('.header-searchfield input')     .on('input', function () {         var value = $(this).val();         $(this).mobileheaderautocomplete('suggest', value);     }); 

i want call when clicking button (outside input element, widget attached to), doesn't work:

$('.header-searchfield__close-button').on('click', function () {     $('.header-searchfield input').data('mobileheaderautocomplete').clear(); } 

the error in js console uncaught typeerror: cannot read property 'clear' of undefined

i used this answer reference , tried ui-mobileheaderautocomplete. missing here?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -