is there any way to use the function from js file to phtml file. Below is the js file that i have called through the data-mage-init.
define([
'jquery',
'jquery/ui'
], function($) {
'use strict';
$.widget('mage.simple2', {
_method2: function() {
console.log('method2');
},
_method: function() {
console.log('method');
}
});
return $.mage.simple2;
});
this file is call using the below line in phtml file
<input type="text" data-mage-init="{"Vendor_Simple2/js/simple2"}" />
Now i want to call _method or _method2 in phtml file. Is that possible?
Please share if anyone have idea about that.
Thanks.