Search code examples
javascriptbackbone.jsbackbone-stickit

How to bind element attributes in backbone stickit?


I want to define an anchor tag href in my backbone stickit bindings, such that whenever a model attribute updates, the href of my anchor tag updates

Something like this,

bindings : {
    ".facebook-profile-icon('href')" : "facebook"
    ".twitter-profile-icon('href')" : "twitter"
}

Currently, I am doing something like this :

bindings : {
    ".facebook-profile-icon" : "facebook"
    ".twitter-profile-icon" : "twitter"
}

render : function(){
  this.stickit();
}

This just(understandably) updates the html of the classes instead of updating the hrefs.

Is there a way i can do this in backbone stickit?


Solution

  • Backbone.StickIt is well documented. In your case you want to update attributes, so you might use: https://nytimes.github.io/backbone.stickit/#attributes