I am trying to get other scripts to execute when i load a knockout component that will impact the GUI, however when the component executes they simply dont attach to elements on the DOM, however no errors are thrown either. Below i am using a external telephone plugin that i want to bind to a textbox called input when the module loads, however nothing happens.
define(...dependencies....)
function Register()
{
var input = $("#phone_no");
input.intlTelInput({
preferredCountries: ['za', 'gb', 'bw', 'na', 'ls'],
numberType: "MOBILE",
nationalMode: true,
});
}
Register.prototype.init = function()
{
var input = $("#phone_no");
input.intlTelInput({
preferredCountries: ['za', 'gb', 'bw', 'na', 'ls'],
numberType: "MOBILE",
nationalMode: true,
});
}
... other prototypes...
return {
viewModel: { instance: new Register() },
template: login,
};
If i open up the console once the template is in view and i execute:
var a = require('components/register')
a.viewModel.instance.init()
It binds correctly to the control. How can i control within the module when to run scripts that i want executed.
Thanks