destroy button widget fails with "this.button is undefined" error #7490

Closed
fdummert opened this Issue Jun 11, 2014 · 2 comments

Projects

None yet

3 participants

@fdummert

The _destroy method of a form button widget has a reference to "this.button" which is never populated:

_destroy: function() {
    this.element.insertBefore( this.button );
    this.button.remove();
}

A $(...).button("destroy") call consequently fails with an "this.button is undefined" error.

This bug was introduced by this commit and could be resolved by replacing "this.button" with "this.wrapper":

_destroy: function() {
    this.element.insertBefore( this.wrapper );
    this.wrapper.remove();
}
@jaspermdegroot
Member

@fdummert

Thanks for reporting the issue. Please, always include a test page when reporting bugs. See our contributing guidelines.

I created one for this issue: http://jsbin.com/sekujuqa/2/edit

@arschmitz - Should button be replaced by wrapper?

_destroy: function() {
    this.element.insertBefore( this.wrapper );
    this.wrapper.remove();
}
@jaspermdegroot jaspermdegroot added this to the 1.4.4 milestone Jun 11, 2014
@gabrielschulhof gabrielschulhof self-assigned this Jun 11, 2014
@gabrielschulhof
Contributor

Yeah, I think that's it. this.button is an instance-level variable that is only referenced in _destroy() and not initialized anywhere.

@gabrielschulhof gabrielschulhof added a commit that referenced this issue Jul 30, 2014
@gabrielschulhof gabrielschulhof Button: Reference wrapper by its correct name in _destroy()
(cherry picked from commit 7d361e9)

Closes gh-7491
Fixes gh-7490
e8c0118
@agcolom agcolom added a commit to agcolom/jquery-mobile that referenced this issue Nov 26, 2014
@gabrielschulhof @agcolom gabrielschulhof + agcolom Button: Reference wrapper by its correct name in _destroy()
Closes gh-7491
Fixes gh-7490
8a57f11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment