Dwain Wuerfel
Dwain Wuerfel

Reputation: 373

onclick event of button requires double click

I have a viewPanel using DB2 for the datasource. I have created a comboBox containing all the possible viewPanel columns, a radioGroup to select ASC or DESC, a comboBox containing all the possible viewPanel columns with an onchange event to partially update the values in another comboBox, and a final comboBox that has all the values from DB2 according to the previous comboBox value that has an onchange event to partially update the viewPanel.

The onclick event for my button has this code and does a partial update of the viewPanel:

var sort:String = getComponent('comboBox1').getValue();
var order:String = getComponent('radioGroup1').getValue();
var vp = getComponent('panel_container').getData()[0];
vp.setDefaultOrderBy(sort + " " + order)

The problem is that I have to click the button twice to get the code to actually run. The first click is ensuring the onchange event is fired, then the second click activates the code. I have tried to use Full Update and checking the 'Set partial execution mode' with the partial update.

How do I get the onclick event for my button to work on the first click?

Upvotes: 0

Views: 564

Answers (1)

stwissel
stwissel

Reputation: 20384

Too much event tango :-) Here is what I would do:

  • bind your combo boxes to viewScope variables. That's more robust than getValue() and allows to change the UI later (fancy some d&d)
  • use the combo box client side, not the server side onChange() event. This would require all values to be send down eg via Ajax
  • when you click the button make sure the fields are inside the panel you refresh

Hope that helps

Upvotes: 1

Related Questions