Modify

Opened 9 years ago

Closed 9 years ago

#12538 closed defect (fixed)

Can't change select dropdown value

Reported by: Chris Heller Owned by: Ryan J Ollos
Priority: normal Component: DynamicVariablesPlugin
Severity: major Keywords:
Cc: Trac Release:

Description

I'm not sure if this is just something with particular environment configuration, but I was repeatedly getting stuck on not being able to change the value for a dynamic variable. The dropdown was populated properly, but the value would not stick. The form was properly submitted to the server though.

it turns out the problem is in this line

input.val(select.val()); // set hidden text input

The select.val() portion was always returning undefined for some reason, even when an option was selected. I tested this on a few different browsers and had the same behavior.

Attachments (0)

Change History (6)

comment:1 Changed 9 years ago by Chris Heller

Here's the diff for what ended up fixing it.

  • dynvars/templates/dynvars.html

     
    2525        var select = jQuery(this);
    2626        var name = select.attr('id');
    2727        var input = jQuery('#prefs input[name='+name+']');
    28               input.val(select.val()); // set hidden text input
     28              var optionSelected = select.find("option:selected");
     29              var valueSelected  = optionSelected.attr("value");
     30              input.val(valueSelected)  // set hidden text input
    2931              input.parents('form:first').submit();
    3032          });
    3133      }

By grabbing the selected option and getting its value attribute (.val() doesn't give the correct answer here either) and using that to populate the hidden input field, then things worked.

I didn't do any further troubleshooting to determine what was causing the original problem though.

comment:2 Changed 9 years ago by Ryan J Ollos

I can't reproduce and the code appears correct. Could you explain a bit more what you mean by the value would not stick? Do you see any errors in the JavaScript console? Do you have any other plugins installed? Which version of Trac are you running?

comment:3 Changed 9 years ago by Ryan J Ollos

In 14917:

0.2.0dev: Replace virtual script with a script.

Use add_script_data to pass data to the script.

Refs #12538.

comment:4 Changed 9 years ago by Ryan J Ollos

Owner: changed from Rob Guttman to Ryan J Ollos
Status: newaccepted

Could you please try the new version of the plugin and report back? The code is simpler now, the performance should be better and it should be easier to debug.

comment:5 Changed 9 years ago by Ryan J Ollos

In 14918:

0.2.0dev: Remove debug alert dialog.

Refs #12538.

comment:6 Changed 9 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

Feel free to follow-up if you continue to have issues.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.