Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Firefox show the correct default select option?

I'm making a web app to manage product SKUS. One part of that is to associate SKUs with product names. On each row of a table, I list a SKU and display a <select> box with product names. The product that's currently associated with that SKU in the database is given an attribute like selected="selected". This can be changed and updated via AJAX.

There are a lot of product <option>s - 103 to be exact - and this list is repeated in the <select> on each row.

From another input on the page, I am using jQuery AJAX requests to add new SKU/product associations, and to make it clear that they're added instantly, I insert them into the top of the table with a little highlight effect. As the number of SKUs increases past 10 or so, if I refresh the page (which loads everything back out of the database ordered by product name), Firefox starts to show some wrong options as selected by default. It is not consistent about which incorrect option it shows, but it seems to be mixing up the options that existed before the page reload.

If I inspect the <select> using Firebug, the select="selected" is on the correct <option> tag. Refreshing the page (or leaving and typing this page's URL back in to return) does not make it show up correctly, but hard refreshing (Ctrl+F5) does.

Both Chrome and IE7 display this correctly in the first place.

My theory is that this is a result of a faulty cache strategy by Firefox. Does that sound right? Is there any way I can say in my code "if this page is refreshed, make it a hard refresh - reload everything from scratch?"

Update

To solve this problem, I changed strategies.

  • Previously, I put a <select> with a long list of <option>s on each table row, with the current value set as default
  • Now, I put the current value in a <span>. If the user clicks a "change" button, I replace the <span> with a <select>, and the "change" button becomes a "confirm" button. If they change options and click confirm, AJAX updates the database, the and the <select> goes back to being a <span>, this time with the new value.

This has two benefits:

  • It fixes the bug described above
  • It requires far fewer DOM elements on the page (all those redundant <option>s)
like image 785
Nathan Long Avatar asked Sep 25 '09 19:09

Nathan Long


People also ask

Where is the Firefox Options menu?

Click the orange Firefox button to open the menu, then click on the word Options to open the options window. On the Menu Bar click on Tools, Options is the last on the list. On the Menu Bar click on Tools, Options is the last on the list.

Where is Firefox preferences located?

In the Menu bar at the top of the screen, click Firefox and select Preferences. Click the menu button.

Why can't I make Firefox my default browser?

Change the default browser in Settings Press Win + I on the keyboard to open the Settings app. Choose Apps and go to Default apps. Find and go to Firefox. Click on Set default as shown in the screenshot.


1 Answers

I had a similar problem, but after adding autocomplete="off" HTML attribute to every select tag it worked. [I was using Firefox 8]

like image 109
BananaDeveloper Avatar answered Sep 22 '22 15:09

BananaDeveloper