Giter VIP home page Giter VIP logo

Comments (3)

misantronic avatar misantronic commented on June 12, 2024

You would rather control this in your View.
Something like:

bindings: {
    '#uRepeateverybyweek': {
        observe: 'uRepeateverybyweek',
        onGet: function(val) {
            var displayMode = val ? 'inline-block' : 'none';

            this.$('#uRepeateverybyweek').css('display', displayMode);
        }
    }
}

from backbone.stickit.

kdbusiness90 avatar kdbusiness90 commented on June 12, 2024

Hi David,

i have tried above code with below HTML but is giving me.

Repeat every:
1 2 3 4 5 weeks

Resultant:

true

On Sat, Dec 26, 2015 at 9:45 PM, David Skx [email protected] wrote:

You would rather control this in your View.
Something like:

bindings: {
'#uRepeateverybyweek': {
observe: 'uRepeateverybyweek',
onGet: function(val) {
var displayMode = val ? 'inline-block' : 'none';

        this.$('#uRepeateverybyweek').css('display', displayMode);
    }
}

}


Reply to this email directly or view it on GitHub
#301 (comment)
.

Kartik*Python | Django | AngularJS Developer *
[image: Skype] kdbusiness90 [email protected] |
[email protected]

from backbone.stickit.

StevenLangbroek avatar StevenLangbroek commented on June 12, 2024

@kdbusiness90 you can remove your if statement. Also a small note, this is highly dependent on how you supply your model to your template. Marionette standardizes this heavily, and underscore templates really don't scale as well as something like Handlebars. All that being said, I wouldn't pass your entire model instance into the view, rather a serialized representation. Also: stickit has built-in capabilities for hiding / showing elements based on model attributes.

var MyView = Backbone.View.extend({
  template: _.template('#my_template'),
  render(){
    this.$el.html(this.template(this.model.toJSON())); // Only pass in serialized Model.
    return this;
  },
  bindings: {
    '#uRepeateverybyweek': {
      observe: 'uRepeateverybyweek',
      update: false, // Don't try to update this element, only make it
      visible(val, options){ return val } // visible depending on `uRepeateverybyweek` attribute
    }
  }
});

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.