Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:11:04+00:00 2026-06-16T01:11:04+00:00

I am using Rivets.js to bind elements to my model. I am using Bootstrap

  • 0

I am using Rivets.js to bind elements to my model. I am using Bootstrap by Twitter for design, and have set up three buttons to choose from the values 1, 2 and 3 (functionally equivalent to radio buttons).

I have set up three buttons in a button group like this:

<div class="btn-group" id="input_level" data-toggle="model.level">
    <button data-toggle-value="1" class="btn active">One</button>
    <button data-toggle-value="2" class="btn">Two</button>
    <button data-toggle-value="3" class="btn">Three</button>
</div>

I have added a custom toggle binder like so:

rivets.binders.toggle = function(el,value){
    $(el).find('button[data-toggle-value="' + value + '"]')
        .addClass('active').siblings().removeClass('active');
}

This updates the button state like it should, but doesn’t work the other way – i.e. there is no event bound to the button click event. I want to generalize this to Rivets.js so I don’t have to add a click event to each button group in the form in the Backbone view.

Is this basic functionality in Rivets, and if so, how do I set it up?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:11:05+00:00Added an answer on June 16, 2026 at 1:11 am

    After studying the Rivets.js annotated source, I found the solution after a while (I’m not using CoffeeScript, so it was a bit of a hassle to read):

    I replaced this piece of original code in my question:

    rivets.binders.toggle = function(el,value){
        $(el).find('button[data-toggle-value="' + value + '"]')
            .addClass('active').siblings().removeClass('active');
    }
    

    With this:

    rivets.binders.toggle = {
        publishes: true,
        bind: function(el){
            $(el).on('click', 'button:not(.active)', _.bind(function(e){
                this.model.set(this.keypath, $(e.currentTarget).data('toggle-value'));
            }, this));
        },
        unbind: function(el){
            $(el).off('click', 'button:not(.active)');
        },
        routine: function(el,value){
            $(el).find('button[data-toggle-value="' + value + '"]')
                .addClass('active').siblings().removeClass('active');
        }
    };
    

    The initial code is now under rivets.binders.toggle.routine instead of rivets.binders.toggle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the Word Interop API I have a document from which I remove text
Using InteliJ IDEA , I am trying to set up multiple projects to run
Using RestKit 0.10.1, I have objects served similar to this json format: {objects: [
Using SolrNet for querying & faceting. I have a combination of int, tdate and
Using jQuery, how do I get the value from a textbox and then load
Using the WPF Grid control is easy when your child elements are always contained
Using Android NDK is it possible (from native C-code) to get a list of
Using JQuery,Is there any possible to capture images/scanned documents from digital Camera/Scanner Connected to
Using MATLAB, you have to start with a uniform distribution between (0,1). You need
I'm using Rivets.js for two two-way data binding in a Backbone project and would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.