dog
01-07-2015, 07:54 PM
Hi there,
Context:
I'm working on a site that uses require.js to define several controllers, modules and utilities. One util (called utils/forms) adds bespoke controls to all input[type=number] elements that it encounters on page load. I then have a module (called mods/addAnother) that takes a block of markup and appends a cleaned-up copy of it to a given element. That's all good!
Issue:
When using mods/addAnother on a section containing number inputs I'm encountering a problem. The problem is that in utils/forms, events on the bespoke number buttons are bound to make them operational, this happens on page load so the number buttons added by mods/addAnother don't have the binding and therefore aren't operational. I'm struggling to trigger the bind method of utils/forms when the appropriate method of in mods/addAnother runs.
Is this a common issue ...triggering a method defined in one module via a callback in another module? Does require.js (or Javascript in general) allow me to do this in some reasonably simple way that I'm not aware of?
Any help will, as always, be much appreciated.
Thanks,
Laurence
Context:
I'm working on a site that uses require.js to define several controllers, modules and utilities. One util (called utils/forms) adds bespoke controls to all input[type=number] elements that it encounters on page load. I then have a module (called mods/addAnother) that takes a block of markup and appends a cleaned-up copy of it to a given element. That's all good!
Issue:
When using mods/addAnother on a section containing number inputs I'm encountering a problem. The problem is that in utils/forms, events on the bespoke number buttons are bound to make them operational, this happens on page load so the number buttons added by mods/addAnother don't have the binding and therefore aren't operational. I'm struggling to trigger the bind method of utils/forms when the appropriate method of in mods/addAnother runs.
Is this a common issue ...triggering a method defined in one module via a callback in another module? Does require.js (or Javascript in general) allow me to do this in some reasonably simple way that I'm not aware of?
Any help will, as always, be much appreciated.
Thanks,
Laurence