Mastering KnockoutJS by Timothy Moran

Mastering KnockoutJS by Timothy Moran

Author:Timothy Moran [Moran, Timothy]
Language: eng
Format: azw3, mobi, epub
Publisher: Packt Publishing
Published: 2014-11-25T16:00:00+00:00


SammyJS has been added as a dependency and injected in. The RequireJS configuration isn't shown, but it doesn't require a shim. SammyJS plays nicely as an AMD. The pageVm object is created with two observable properties and a helper method for setting them. The order is important because component viewmodels are instantiated synchronously, and the data bound to the params object needs to already be in place when the component name changes; otherwise, the component will initialize before the params objects are set.

After SammyJS has been set up, the document-ready handler starts it using a default route and then applies bindings with the pageVm object.

One way to perform the SammyJS configuration would be to write out each component register and route handler, as follows:

ko.components.register('contact-edit', { require: 'contacts/edit' }); self.get('#/contacts/:id', function() { pageVm.setRoute('contact-edit', { id: this.params.id }); });



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.