GithubHelp home page GithubHelp logo

Comments (6)

andriijas avatar andriijas commented on May 12, 2024
userBindings:
  '#username': 'username'

render: ->
   if loggedin
      @stickit @model, userBindings

in js:

  userBindings: {
    '#username': 'username'
  },
  render: function() {
    if (loggedin) {
       this.stickit(this.model, userBindings);
    }
  }

from backbone.stickit.

delambo avatar delambo commented on May 12, 2024

I second @andriijas' approach - create two bindings objects for the different states.

from backbone.stickit.

malkomalko avatar malkomalko commented on May 12, 2024

on second thought here though, I wonder why the whole thing should bork if one field in your bindings map doesn't exist? I almost feel like it should just ignore bindings that don't exist instead of stopping the train. that would decrease the need for creating logic to handle multiple bindings as in the scenario described... no?

from backbone.stickit.

delambo avatar delambo commented on May 12, 2024

I'm not quite sure if I understand your problem. I setup the following fiddle with a selector to an element that doesn't exist and it seems to work fine:

http://jsfiddle.net/px6UP/6/

Can you modify this fiddle to show me what you are seeing?

from backbone.stickit.

sllanes avatar sllanes commented on May 12, 2024

I ran into this issue recently. The problem is that I was using lodash and not underscore. In the stickit function there is an "each" loop that returns false if the selector does not find an element. It appears lodash's "each" does not support early breaking of the loop while underscore does. I switched to underscore to fix the issue. Is the "return false" intended to be an early break or is it meant to abandon applying the bindings?

I did read that underscore should not support early breaking in each loops but it seems it does in version 1.4.4: jashkenas/underscore#960.

And lodash says it does not support early breaking as well: lodash/lodash#99.

That leaves me a little confused but the switch to underscore does seem to address my problem.

from backbone.stickit.

delambo avatar delambo commented on May 12, 2024

Removed false from that return statement on master.

from backbone.stickit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.