Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9213 closed bug (fixed)

Button: timeout in formResetHandler causing refresh to be called on non-widgets

Reported by: krampstudio Owned by: tj.vantoll
Priority: minor Milestone: 1.10.3
Component: ui.button Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

Description

Why is there a timeout into the formResetHandler function, it causes me a lot of trouble after the upgrade of jQuery to version 1.9.1 ?

The formResetHandler function from jquery-ui 1.10.2:

formResetHandler = function() {
	var buttons = $( this ).find( ":ui-button" );
	setTimeout(function() {
		buttons.button( "refresh" );
	}, 1 );

My use case was to

  1. call the reset method on a form that contains buttons and buttonsets
  2. remove some part of that form that contains those buttons and buttonsets (so removing the buttons)
  3. Because the execution order isn't guaranted due to the setTimeout, I was getting the error: cannot call methods on button prior to initialization; attempted to call method refresh because the button is removed before the form.reset.

I'm wondering if the setTimeout is useful.

See the test case at http://jsfiddle.net/krampstudio/FaFby/1/

Thank you!

Change History (7)

comment:1 Changed 5 years ago by tj.vantoll

Status: newopen
Summary: timeout in formResetHandlerButton: timeout in formResetHandler causing refresh to be called on non-widgets

I believe the setTimeout is there so that the refresh call occurs after the form reset has processed. This is a legitimate use case so I'd say we should probably find buttons within the setTimeout function itself. I'll take a stab at this.

comment:2 Changed 5 years ago by tj.vantoll

Owner: set to tj.vantoll
Status: openassigned

comment:4 Changed 5 years ago by TJ VanToll

Resolution: fixed
Status: assignedclosed

Button: On form reset only call refresh on current button widgets. Fixed #9213: Button: timeout in formResetHandler causing refresh to be called on non-widgets

Changeset: 2de31fdbf498a6c20d196a96d007ea0f069644c5

comment:5 Changed 5 years ago by tj.vantoll

Milestone: none1.11.0

comment:6 Changed 5 years ago by TJ VanToll

Button: On form reset only call refresh on current button widgets. Fixed #9213: Button: timeout in formResetHandler causing refresh to be called on non-widgets (cherry picked from commit 2de31fdbf498a6c20d196a96d007ea0f069644c5)

Changeset: 1152e6591740765d2a1c261714ea9e409bf94cb5

comment:7 Changed 5 years ago by Scott González

Milestone: 1.11.01.10.3
Note: See TracTickets for help on using tickets.