0

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

Piotr Stulinski
  • 9,241
  • 8
  • 31
  • 46
  • I managed to get this working - there are two methods at: [Solution][1] [1]: http://stackoverflow.com/questions/26243756/does-afterrender-work-with-knockout-components/26702397#26702397 – Piotr Stulinski Nov 02 '14 at 17:49
  • Good to hear you solved it. Does that mean your question turned out to be a dupe of linked one? May as well help future visitors then and mark this one as a duplciate. – Jeroen Nov 02 '14 at 18:08
  • 1
    I am not sure i have the reputation to do that... – Piotr Stulinski Nov 02 '14 at 20:06
  • That's okay, was just checking if it was okay with you. If you have the option, hit the "close" action just below your question's tags to add a vote. If not, no probs: others may (or may not) vote for it. – Jeroen Nov 02 '14 at 21:44

0 Answers0