Leahcim
Leahcim

Reputation: 41919

button('reset')

The following Single Page Application (created by someone else) which authenticates users, http://backbonedevise.herokuapp.com was created using Backbonejs and a plugin called Marionette. I am trying to rewrite it without Marionnette. The success and error callbacks have this line of code

el.find('input.btn-primary').button('reset');

Prior to the login the html looks like this

 <input type="submit" value="Login" class="btn btn-primary">

In other words, it doesn't have a type reset. I'm assuming the line el.find('input.btn-primary').button('reset'); somehow resets the button. I tried to rewrite it this way

$('input.btn-primary').button('reset');

but I received an error,

Object has no method button. 

Can you explain what I might be doing wrong and how i might fix it.

The success callback.

this.model.save(this.model.attributes, {
      success: function(userSession, response) {
        el.find('form').prepend(BD.Helpers.Notifications.success("Instructions for resetting your password have been sent. Please check your email for further instructions."));
        el.find('input.btn-primary').button('reset');
      },

Upvotes: 1

Views: 2510

Answers (1)

rockerest
rockerest

Reputation: 10508

Marionette implements a .button() method in it's internals.

It's likely that .button() is a hook to easily manage button states, but I didn't dig too far into it (I don't know anything about Marionette).

Here's the instance in Marionette where .button is defined, although there are plenty of places that reference it that I found:

a.fn.button = function (c) {
        return this.each(function () {
            var d = a(this),
                e = d.data("button"),
                f = typeof c == "object" && c;
            e || d.data("button", e = new b(this, f)), c == "toggle" ? e.toggle() : c && e.setState(c)
        })

What it boils down to is that either you need to figure out what .button() does for you in Marionette and re-implement it yourself, or do without it entirely.

For what it's worth, jQuery UI has a .button method, too, so since you're still using jQuery, you could plug that in.

Upvotes: 3

Related Questions