Skip to content
Namespaces plugin for KnockoutJS
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build Updated templates example May 23, 2011
examples Updated templates example May 23, 2011
spec
support Implemented templating with namespaces. Added templates.html example. May 23, 2011
.gitignore Checking to see if namespace is undefined before trying to slice on it. May 23, 2011
README.md Updated README for templates May 23, 2011
knockout.namespaces.js

README.md

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://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

You can’t perform that action at this time.