npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

marionette.binding

v0.0.11

Published

Marionette.js bindings

Downloads

40

Readme

Marionette.Binding.js

Circle CI

NPM

This provides two-way UI bindings to marionette.js.

Demo

Currently the fastest way to get a demo up and running is to do the following:

git clone https://github.com/kennydude/marionette-binding.git
cd marionette-binding
npm install
[sudo] npm install beefy
beefy demo.js

Open a browser to http://localhost:9966/demo.html

(Hopefully a live demo can be put together soon)

Usage

This is designed for usage via Browserify and it's fairly simple. There are two ways to activating Marionette.Binding:

  • Reconmended route: If you already extend from LayoutView you can just swap this out for MarionetteBinding.BindedView
  • Otherwise you'll have to use the mixin MarionetteBinding.BindingMixin (more details coming soon)

You're views are exactly the same and we reconmend you use the ui hash to keep things neat.

Now all you need is to setup the bindings hash like so:

var DemoView = MarionetteBinding.BindedView.extend({
  // ... other stuff ...
  ui: {
    "text": "#text",
    "repeat": "#repeat",
    "text_2": "#text_2",
    "repeat_2": "#repeat_2"
  },
  bindings: {
    "value @ui.text": "name",
    "text @ui.repeat": "name",
    "value @ui.text_2": "place",
    "html @ui.repeat_2": "place"
  }
  // ... other stuff ...
});

The keys on the binding work similar to triggers, but instead of events it's where you want the value to go.

Also if you override onRender the bindings you will have to hook up bindings like so:

onRender: function(){
  // .. other stuff ...
  this.startBindings()
},

Binding definition

The definition is always:

"how_you_want_to_bind what_to_bind" : "bind_to_what"

How you want to bind can be one of the following:

  • value or val which is an input's value (or anything $.val works on)
  • text is setting the text contents
  • html sets the innerHTML. Warning: This could be dangerous! Don't use this ever on user-input unless you absolutely mean to
  • checked deals with with input radios or checkboxes
  • disabled adds or removes the disabled attribute based on a true/false value
  • visible hides/shows based on true/false value
  • class will add/remove a class if used by class:some_class or set the class attribute by whatever the value is

The bind_to_what value also accepts "lookups", which are modelled after Django. Currently available:

  • isnull returns true/false if the value is null or not
  • not returns the opposite value

License

The MIT License (MIT)

Copyright (c) 2015 Joe Simpson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.