Skip to content

hunterloftis/knockout.namespaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knockout.namespaces

Multiple KnockoutJS ViewModels (separated by namespaces). Compatible with the global namespace as well (standard global 'data-bind' ViewModel).

Download

Try

$ git clone git:https://github.com/hunterloftis/knockout.namespaces.git
$ cd knockout.namespaces/examples
$ open simple.html

Code

<script src="knockout-latest.js"></script>
<script src="knockout.namespaces-latest.js"></script>
...
<span data-bind-user="text: name">
<span data-bind="text: title"> <!-- works with regular bindings -->
...
<script>
  ko.applyBindings(globalViewModel);
  ko.applyBindings(userViewModel, 'user');
</script>

Use cases

  • Multiple ViewModels
  • Ajaxed ViewModels
  • Loosely coupled architecture
  • Dynamic binding
  • Data-bound controls and modules

Templates

Namespaced templates are a work-in-progress. Check out /examples/templates.html. They work for common use cases, but such actions as nesting multiple templates of different namespaces together may have unpredictable results. I would love some help coming up with a solution.

Related

About

Namespaces plugin for KnockoutJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published