waseem02 / jquery-asmselect

Automatically exported from code.google.com/p/jquery-asmselect
0 stars 0 forks source link

Page doesn't rener with dynamically generated options under Firefox #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Dynamically create the original option list using JavaScript (example 
uses a few simply document.write commands but actual code is much more 
complicated. The data used to generate the options is obtained through a 
client-side inlude.
2. Enable asmselect

What is the expected output? What do you see instead?

In IE7, Chrome, and Safari, the page is rendered corectly and the 
asmselect feature functions properly. No errors reported.

In Firefox, the page never finishes loading. The only thing that appears 
in the browser is the text of of the select option items...all on the 
first line. Nothing else appears.

What version of the product are you using? On what operating system?
Windows XP-SP3 (32-bit)
jquery.asmselect: 1.0.4 beta
jquery: 1.2.6
jquery.ui: 1.5.1
IE: 7
FF: 3.0.5
Chrome: 1.0.154.36
Safari: 3.2.1

Attached are two files....one with explicit HTML (sample_no_js.htm) and 
one with javascript generating the select options (sample_js.htm).

Code snippet of what is different between the two:

<select id=Official name=Official  multiple=1 title="Official">
    <option value=1>text1</option>
    <option value=2>text2</option>
    <option value=3>text3</option>
    <option value=4>text4</option>
</select>

<select id=Official name=Official  multiple=1 title="Official">
    <script type="text/javascript">
        document.write('<option value=1>text1</option>');   
        document.write('<option value=2>text2</option>');   
        document.write('<option value=3>text3</option>');   
        document.write('<option value=4>text4</option>');   
    </script>
</select>

Please provide any additional information below.

Original issue reported on code.google.com by cbrust...@gmail.com on 8 Jan 2009 at 10:35

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This is not specific to asmSelect as far as I can tell. I removed asmSelect
completely from your example (sample_js.htm), so that it was just a plain HTML
document without JS or CSS, and the behavior is the same in Firefox. 

I am assuming that you can't dynamically write options in Firefox with
document.write(). I am also wondering why the document.write() is being used, 
as it
seems unnecessary? As you'd indicated, your actual usage is more complex, so I'm
assuming there is a reason why you need to output these with JS. If that is the 
case,
these likely need to be done inside a $(document).ready() function, and 
appended in
the select, regardless of whether you use asmSelect or not. 

Thanks,
Ryan

Original comment by ryancram...@gmail.com on 21 Feb 2009 at 4:00

GoogleCodeExporter commented 8 years ago
Opps, looks like I inadvertently deleted my followup comment.....but here it is 
again....

After doing some more research, I've found the problem...the order that 
document.write is executed relative to other code causes it to reset the page 
(at 
least for FireFox). And since all it does is write the select list text, that 
is all 
I got. I've changed it to use the DOM and it now works correctly in all 4 
tested 
browsers.

As an aside, the reason I'm using JS to generate the lists is that the lists 
can be 
fairly large, hundreds of options (upto about 20k-30k of content), and I send 
the 
data in a seperate request so the browser can cache it and use it on several 
subsequent pages. In fact, the same data can be used generate up to 5 different 
selects.....so you can see the advantage of depending on the browser cache to 
improve performance.

Original comment by cbrust...@gmail.com on 21 Feb 2009 at 6:10