Hi,
I am trying to re-populate a selection using prototype and it works
just fine with
FireFox, however, it does not with MS IE (>=6.0). It always results in
an empty selection list.
Checking the DOM with IE DOM Inspector reveals <select
id="..."></select>, no options whatsoever.
My invoker:
function invokeLoadSelection(form, event, container, value) {
if (event != null) params = event + ''&contentSection=''
+ $F(value);
var req = new Ajax.Updater({success: container}, form.action, {
method: ''post'', postBody: params });
}
The stripes resolution produces a simple string with <option...> tags:
>>>
String res = "";
DataManager dm = new DataManager();
List items = dm.contentBySection(contentSection);
for( Object ct : items ) {
res += "<option value=\"" +
((Content)ct).getId().toString().trim()
+ "\">";
res += ((Content)ct).getTitle().trim() + "</option>";
}
return new StreamingResolution("text/html", new StringReader(res));
<<<
Can anyone !please! point me in the right direction as to why the
*!*@*#! it doesn''t work
in IE?
Thanks,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Element.update() uses innerHTML property and IE doesn''t support
innerHTML property on select boxes.
I usually get a JSON object back from the server for select drop downs
and loop through it with something like this:
var select = $(''mySelect'');
for (var i=0; i<options.length; i++)
select.options[i] = new Option(options[i].name, options[i].value);
The JSON looks something like this:
{ ''options'': [{''name'':''the
name'', ''value'':''the value''},
{''name'':''another name'',
''value'':''another value''}] }
Hope that gives some direction.
--
Brandon Aaron
On 10/2/06, Chris <mail-LyRAhpaJHUdBDgjK7y7TUQ@public.gmane.org>
wrote:>
> Hi,
>
> I am trying to re-populate a selection using prototype and it works
> just fine with
> FireFox, however, it does not with MS IE (>=6.0). It always results in
> an empty selection list.
> Checking the DOM with IE DOM Inspector reveals <select
> id="..."></select>, no options whatsoever.
>
> My invoker:
>
> function invokeLoadSelection(form, event, container, value) {
> if (event != null) params = event +
''&contentSection='' + $F(value);
> var req = new Ajax.Updater({success: container}, form.action, {
> method: ''post'', postBody: params });
> }
>
> The stripes resolution produces a simple string with <option...>
tags:
>
> >>>
> String res = "";
> DataManager dm = new DataManager();
> List items = dm.contentBySection(contentSection);
>
> for( Object ct : items ) {
> res += "<option value=\"" +
((Content)ct).getId().toString().trim()
> + "\">";
> res += ((Content)ct).getTitle().trim() + "</option>";
> }
>
> return new StreamingResolution("text/html", new
StringReader(res));
> <<<
>
> Can anyone !please! point me in the right direction as to why the
> *!*@*#! it doesn''t work
> in IE?
>
> Thanks,
> Chris
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Brandon, Thanks! That does help indeed. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Chris, I think this is just a limitation with IE. I say this because I
ran into this same problem and my final solution involved dom manipulation.
Here it is:
javascript:
-------------
function fillSelectFromObject(receiver,obj){
var box = $(receiver);
box.options.length = 0;
var sel = obj.selected || false;
var opts = obj.options;
for( var i=0; i<opts.length; i++ ){
box.options[i] = new
Option(opts[i].text,opts[i].value,null,(sel&&sel==opts[i].value?true:false));
}
if( obj.selectedIndex ) box.selectedIndex = obj.selectedIndex;
}
--------------
obj in the above function is usually passed from the server as a JSON
string that has been evaluated (e.g.
onComplete(xhr,obj){fillSelectFromObject(''myselect'',obj);).
I use PHP so my code to generate the results is as follows:
-------------
$options = Array( ''selectedIndex'' => 0,
''options'' => Array(
Array(''value'' => ''0'',
''text'' => $voidMsg) ) );
while( $person = fetchAssoc($result) )
array_push($options[''options''],Array(''value''
=>
$person[''person_id''], ''text'' =>
$person[''name'']));
print json_encode(unescape($options)); //this isn''t using X-JSON
header but it could easily do so
--------------
The result is something like (JSON):
------------------
{
selectedIndex: 0, /* or could be: selected: ''91'' to select
''Bobby Mercer'' */
options: [ /* note, an array, not a hash */
{value: ''5'', text: ''John Smith''}, /*
I used ''value'' and ''text''
since numerical values didn''t get along well with arrays/hashes, it
would re-index them improperly so a hash was necessary */
{value: ''82'', text: ''Jane Doe''},
{value: ''91'', text: ''Bobby Mercer''}
]
}
-----------------
I hope this helps.
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Ahh, you beat me to it :) On a side note, if you absolutely must use innerHTML, I''m pretty sure it works if you give it an entire select. e.g.: element.innerHTML = ''<select><option value="5">John Smith</option></select>''; That''s how I did it before I saw the light that was Prototype, even though my solution doesn''t actually use any Prototype.. Colin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Wouldn''t you have to use the outerHTML property (IE only) if you included the <select>? Brandon On 10/2/06, Colin Mollenhour <eliteii92g-NPSFNn/7+NYVo650/ln6uw@public.gmane.org> wrote:> > Ahh, you beat me to it :) > On a side note, if you absolutely must use innerHTML, I''m pretty sure it > works if you give it an entire select. e.g.: > > element.innerHTML = ''<select><option value="5">John > Smith</option></select>''; > That''s how I did it before I saw the light that was Prototype, even > though my solution doesn''t actually use any Prototype.. > > Colin > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thanks to you too Colin! Now that you and Brandon mentioned it I found the bug report at MS. It''s an acknowledged bug since 2003... Thanks again! Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I didn''t mean the innerHTML of the select, just that you can use
innerHTML (of some element, i.e. a div) in combination with the html of
the select containing the options if you really want to use an
innerHTML method. I''ve never tried outerHTML with a select but overall
innerHTML/outerHTML is not a great way of doing it so it doesn''t really
matter. I.e. if you have event listeners or other properties that are
set, the outerHTML or innerHTML would have to take that into account.
Also, it is more verbose and harder to read.<br>
<br>
Brandon Aaron wrote:
<blockquote
cite="mid4013241a0610021508k50c7a53mfbf6a353c2ac7644-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org"
type="cite">
<pre wrap="">Wouldn''t you have to use the outerHTML
property (IE only) if you
included the <select>?
Brandon
On 10/2/06, Colin Mollenhour <a class="moz-txt-link-rfc2396E"
href="mailto:eliteii92g-NPSFNn/7+NYVo650/ln6uw@public.gmane.org"><eliteii92g-NPSFNn/7+NYVo650/ln6uw@public.gmane.org></a>
wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Ahh, you beat me to it :)
On a side note, if you absolutely must use innerHTML, I''m pretty sure
it
works if you give it an entire select. e.g.:
element.innerHTML = ''<select><option
value="5">John
Smith</option></select>'';
That''s how I did it before I saw the light that was Prototype, even
though my solution doesn''t actually use any Prototype..
Colin
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group. <br> To post to this
group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To
unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
<br> For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs <br>
-~----------~----~----~----~------~----~------~--~---<br>
</body>
</html>
<br>
Ok, I''m still not getting real warm with this :-(
How should I invoke the Ajax.Updater for this to work? Here''s what I
did (note that I don''t know how to pass the container as a param for
onComplete...):
function invokeLoadSelection(form, event, container, value) {
if (event != null) params = event + ''&contentSection=''
+ $F(value);
var req = new Ajax.Updater(container, form.action, { method:
''post'', postBody: params, onComplete: loadSelection });
}
The server side produces the following JSON formatted string and
returns for example this: {"options":[{"1":"Test
Page"}]}
So everything should be fine for:
function loadSelection(obj) {
var box = $(''contentPages''); // container should be
passed but I
don''t know how...
box.options.length = 0;
var opts = obj.options;
for( var i=0; i<opts.length; i++ ) {
box.options[i] = new
Option(opts[i].text,opts[i].value,null,false);
}
}
The problem is that obj.options not existent and opts = void.
What am I doing wrong?
Thanks,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
If you want to use Ajax.Updater and have the element available use an
insertion rather than onComplete like so:
new Ajax.Updater(''select_element_id'',{
insertion: loadSelection
....
}
});
function json_decode(txt){
try{
return eval(''(''+txt+'')'');
}catch(ex){}
}
function loadSelection(box,response){
var obj = json_decode(response);
box.options.length = 0;
var opts = obj.options;
for( var i=0; i<opts.length; i++ ) {
box.options[i] = new Option(opts[i].text,opts[i].value,null,false);
}
}
onComplete does not get the element to be updated as a parameter, which
sucks, but that''s how it is. This restricts you from using X-JSON
headers effectively with Ajax.Updater.
Also, the server-side JSON you are generating is going to give you
problems, when arrays are reconstructed and the index is a string that
can be a numeric value, it might reindex them. i.e.
{"options":[{"1":"Test Page"}]} might very well
become
{"options":[["Test Page"]]}. I know this is what php was
doing, not sure
if the javascript does it like this as well, but it is much safer to use
the format like Brandon or I suggested earlier:
{"options":[{"value":"1","text":"Test
Page"}]}
The reason opts was null in your onComplete was that it is assigned only
from the X-JSON header if it exists. If you just print the JSON then you
have to access it in the xhr.responseText and eval it yourself (i.e.
using my json_decode() function).
Colin
Chris wrote:> Ok, I''m still not getting real warm with this :-(
>
> How should I invoke the Ajax.Updater for this to work? Here''s what
I
> did (note that I don''t know how to pass the container as a param
for
> onComplete...):
>
> function invokeLoadSelection(form, event, container, value) {
> if (event != null) params = event +
''&contentSection='' + $F(value);
> var req = new Ajax.Updater(container, form.action, { method:
> ''post'', postBody: params, onComplete: loadSelection });
> }
>
> The server side produces the following JSON formatted string and
> returns for example this: {"options":[{"1":"Test
Page"}]}
>
> So everything should be fine for:
>
> function loadSelection(obj) {
> var box = $(''contentPages''); // container should be
passed but I
> don''t know how...
> box.options.length = 0;
>
> }
>
> The problem is that obj.options not existent and opts = void.
> What am I doing wrong?
>
> Thanks,
> Chris
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
A couple notes... Chris a écrit :> How should I invoke the Ajax.Updater for this to work? Here''s what I > did (note that I don''t know how to pass the container as a param for > onComplete...): > > function invokeLoadSelection(form, event, container, value) { > if (event != null) params = event + ''&contentSection='' + $F(value); > var req = new Ajax.Updater(container, form.action, { method: > ''post'', postBody: params, onComplete: loadSelection }); > }If you do not intend for automatic content updates to occur (through insertions or Element.update calls), you should *not* use Updater. Use Ajax.Request instead. Also, as a reply to Collin''s remark that onComplete does not get the updated element as an argument: - this is because onComplete is Ajax.Requester-defined - nothing prevents you from using lexical closure if you define the onComplete code inline - if you reference an outside function, just bind to it and provide the extra argument (Function.bind not only /binds/ but also can provide prefixed arguments). -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
Thanks Colin, I tried and still ... :-(
This is what I got:
function json_decode(txt) {
try {
return eval(''(''+txt+'')'');
} catch(ex) {}
}
function invokeLoadSelection(form, event, container, value) {
if (event != null) params = event + ''&contentSection=''
+ $F(value);
var req = new Ajax.Updater(container, form.action, { method:
''post'', postBody:params, insertion: loadSelection });
}
function loadSelection(container, response) {
var box = $(container);
box.options.length = 0;
var opts = json_decode(response);
for( var i=0; i < opts.length; i++ ) {
alert( x1 + " : " + x2 );
var x1 = opts[i].name;
var x2 = opts[i].value;
box.options[i] = new Option(x1 , x2, null, false);
}
}
The result string in response.responseText is { ''options'':
[{''name'':''Test Page'',
''value'':''1''}] }
However, even so loadSelection is being executed, execution ends right
after the evaluation. The alert is never shown. Why???
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Could you explain this further? It seems to me the ideal would be that Ajax.Updater simply pass the element as a third argument to onComplete prototype.js 1.5.0_rc1 :848 from onComplete(transport, object); to onComplete(transport, object, this.containers.success); Problem solved once and for all, and completely backward compatible. Christophe Porteneuve wrote:> - nothing prevents you from using lexical closure if you define the > onComplete code inline--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
In my last post, please note that no errors are produced. It''s ''just'' that the for() loop somehow never gets executed. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
You broke the code I gave you :)
Notice in the JSON that at the top level, your resulting object is a
hash with key of ''options'' and the value of that key is an
array of more
hashes.
So your code:
------
var opts = json_decode(response);
------
should be:
------
var obj = json_decode(response);
var opts = obj.options; //think of this as obj[''options''] if
you are
more familiar with PHP arrays
------
The loop structure used is designed for arrays, but in your code, opts
is a hash {options: []} and in mine, it is an array [{},{}] (the value
of the options key).
I.e. the.length attribute doesn''t work with a hash, hence the loop
doesn''t work.
Also, you are alerting before x1 and x2 have been assigned.
The rest should work from there.
Colin
Chris wrote:> Thanks Colin, I tried and still ... :-(
>
> This is what I got:
>
> function json_decode(txt) {
> try {
> return eval(''(''+txt+'')'');
> } catch(ex) {}
> }
>
> function invokeLoadSelection(form, event, container, value) {
> if (event != null) params = event +
''&contentSection='' + $F(value);
> var req = new Ajax.Updater(container, form.action, { method:
> ''post'', postBody:params, insertion: loadSelection });
> }
>
> function loadSelection(container, response) {
> var box = $(container);
> box.options.length = 0;
> var opts = json_decode(response);
>
> for( var i=0; i < opts.length; i++ ) {
> alert( x1 + " : " + x2 );
> var x1 = opts[i].name;
> var x2 = opts[i].value;
> box.options[i] = new Option(x1 , x2, null, false);
> }
> }
>
> The result string in response.responseText is {
''options'':
> [{''name'':''Test Page'',
''value'':''1''}] }
>
> However, even so loadSelection is being executed, execution ends right
> after the evaluation. The alert is never shown. Why???
>
> Chris
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve aka TDD
2006-Oct-03 07:08 UTC
Re: Populating selection not working with IE
Hey there, Colin Mollenhour a écrit :> Could you explain this further?What? Lexical closure? I mean you can do something like: new Ajax.Updater(''someId'', ''/someURL'', { .... onComplete: function(transport, object) { var obj = $(''someId''); ... } }); As for binding, you could pre-bind, but this would require your signature be changed, like so: ... onComplete: myCompleteFx.bind(yourBoundObject, $(''someId'')) ... function myCompleteFx(updatedElement, transport, object) { ... }> It seems to me the ideal would be that Ajax.Updater simply pass the > element as a third argument to onComplete > prototype.js 1.5.0_rc1 :848 > from > onComplete(transport, object); > to > onComplete(transport, object, this.containers.success);''would do it, yes. You may want to svn checkout Spinoffs, change line 225 (I think) of prototype/src/ajax.js, add a unit test, and submit a tested patch to the Trac. ''best, -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
I just noticed this too ... time to sleep- it''s one of *those* days
where I can''t see the truck before it runs me over.
Anyway, it now works- again for Mozilla based browsers. Stupid IE
produces, again, an empty selection box... what''s now wrong with IE?
function json_decode(txt) {
try {
return eval(''(''+txt+'')'');
} catch(ex) {}
}
function invokeLoadSelection(form, event, container, value) {
if (event != null)
params = event + ''&contentSection='' + $F(value);
var req = new Ajax.Updater(container, form.action, { method:
''post'', postBody: params, insertion: loadSelection });
}
function loadSelection(container, response) {
var opts = json_decode(response);
var obj = $(container);
obj.options.length = 0;
for( var i=0; i < opts.options.length; i++ ) {
obj.options[i] = new Option(opts.options[i].name,
opts.options[i].value, null, false);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---