I have to call and pass value to the js function(showPopup())from the template(when clicking the Verify OTP button). How to achieve this?. But now i am not able to call the js function.
layout file
<item name="telephone" xsi:type="array">
<item name="config" xsi:type="array">
<item name="elementTmpl" xsi:type="string">Vendor_module/form/element/phone.html</item>
<item name="tooltip" xsi:type="array">
<item name="description" xsi:type="string" translate="true">For delivery questions.</item>
</item>
</item>
</item>
Vendor_module/view/frontend/web/js/view/form/element/phone.js
define([
'Magento_Ui/js/form/form'
], function(Component) {
'use strict';
return Component.extend({
defaults: {
template: 'Vendor_module/form/element/phone',
},
initialize: function () {
this._super();
// component initialization logic
return this;
},
/**
* Form submit handler
*
* This method can have any name.
*/
showPopup: function(){
i need to get my phone number
}
});
});
Vendor_module/view/frontend/web/template/form/element/phone.html
<!-- input field element and corresponding bindings -->
<input class="input-text" type="number" data-bind="
value: value,
valueUpdate: 'keyup',
hasFocus: focused,
attr: {
name: inputName,
placeholder: placeholder,
'aria-describedby': noticeId,
id: uid,
disabled: disabled
}" />
<!-- additional content -->
<div class="primary">
<button class="action primary" data-bind="click:showPopup">
<span>Verify OTP</span>
</button>
</div>