A general rule I follow when using KnockoutJS is that there should be no DOM manipulation in the viewModel. The viewModel should be completely independent of any markup, while any changes to the DOM (via jQuery or otherwise) should be handled in the binding handler. This makes your viewModels much more portable and testable. As […]
2016
KnockoutJS: multiple jquery actions in one binding handler
5th August, 2016 - Posted by david
Passing options to Reveal modal in Foundation via HTML
18th March, 2016 - Posted by david
In my current job, we use Foundation for stuff like modal popups, fancy drop downs etc. I haven’t used it too much but I know for the modal dialogs you can either instantiate them via Javascript ($(‘#elem’).foundation(‘reveal’, ‘open’, {option: ‘value’});) or via HTML attributes (<a href=”#” data-reveal-id=”elem”>Open</a> and <div id=”elem” data-reveal>). Passing options to Foundation […]
Autocomplete with KnockoutJS
3rd February, 2016 - Posted by david
Recently I started a new job at a company that is looking to transition away from a customised, unstructured, jQuery module set up to use KnockoutJS and RequireJS for it’s modules. This approach was chosen because the core platform is based on Magento and the forthcoming Megento 2 uses KnockoutJS heavily throughout it’s frontend templates. […]