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

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -