I apologize if my question duplicates something asked before. I''m new
to JS programming and a search of this group didn''t provide an answer.
I''m trying to interface an existing application framework to
Prototype. I have a small set of JS functions the framework calls to
use the Prototype library.
One of the functions creates multiple instances of Ajax.Updater when a
form is submitted. Only the first Ajax.Updater works, the rest don''t
do anything. Here is the code:
/** Update multiple areas (HTML container elements).
* @param areaCsvString The area CSV string. The CSV string is a flat
array in the
* form of: areaId, target, target parameters [, areaId, target,
target parameters...].
*/
function ajaxUpdateAreas(areaCsvString) {
var areaArray = areaCsvString.split(",");
var numAreas = parseInt(areaArray.length / 3);
for (var i = 0; i < numAreas; i = i + 3) {
new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters:
areaArray[i + 2]});
}
}
I thought maybe the Ajax.Updater instances were erasing each other, so
I put them in array elements - but that didn''t fix the problem.
I have confirmed the string argument passed to the function is
correct. I have confirmed each Ajax.Updater instance works
individually.
Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
I can''t bring myself to tell you what''s wrong (hint:
it''s not
prototype), but try some simple debugging, like putting an
alert(''here'') before/after the Ajax.Updater call, to make sure
your
*loop* is actually working as you expect it to.
On May 19, 11:53 am, adrianc
<adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> I apologize if my question duplicates something asked before. I''m
new
> to JS programming and a search of this group didn''t provide an
answer.
>
> I''m trying to interface an existing application framework to
> Prototype. I have a small set of JS functions the framework calls to
> use the Prototype library.
>
> One of the functions creates multiple instances of Ajax.Updater when a
> form is submitted. Only the first Ajax.Updater works, the rest
don''t
> do anything. Here is the code:
>
> /** Update multiple areas (HTML container elements).
> * @param areaCsvString The area CSV string. The CSV string is a flat
> array in the
> * form of: areaId, target, target parameters [, areaId, target,
> target parameters...].
> */
> function ajaxUpdateAreas(areaCsvString) {
> var areaArray = areaCsvString.split(",");
> var numAreas = parseInt(areaArray.length / 3);
> for (var i = 0; i < numAreas; i = i + 3) {
> new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters:
> areaArray[i + 2]});
> }
>
> }
>
> I thought maybe the Ajax.Updater instances were erasing each other, so
> I put them in array elements - but that didn''t fix the problem.
>
> I have confirmed the string argument passed to the function is
> correct. I have confirmed each Ajax.Updater instance works
> individually.
>
> Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Darrin,
Thanks for pointing that out. The loop was correct originally, but it
got mangled during debugging. The corrected code is:
/** Update multiple areas (HTML container elements).
* @param areaCsvString The area CSV string. The CSV string is a flat
array in the
* form of: areaId, target, target parameters [, areaId, target,
target parameters...].
*/
function ajaxUpdateAreas(areaCsvString) {
var areaArray = areaCsvString.split(",");
var numAreas = parseInt(areaArray.length / 3);
for (var i = 0; i < numAreas * 3; i = i + 3) {
new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters:
areaArray[i + 2]});
}
}
It still doesn''t work in IE.
On May 19, 12:43 pm, darrin
<darrin.ho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I can''t bring myself to tell you what''s wrong (hint:
it''s not
> prototype), but try some simple debugging, like putting an
> alert(''here'') before/after the Ajax.Updater call, to make
sure your
> *loop* is actually working as you expect it to.
>
> On May 19, 11:53 am, adrianc
<adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:
>
> > I apologize if my question duplicates something asked before.
I''m new
> > to JS programming and a search of this group didn''t provide
an answer.
>
> > I''m trying to interface an existing application framework to
> > Prototype. I have a small set of JS functions the framework calls to
> > use the Prototype library.
>
> > One of the functions creates multiple instances of Ajax.Updater when a
> > form is submitted. Only the first Ajax.Updater works, the rest
don''t
> > do anything. Here is the code:
>
> > /** Update multiple areas (HTML container elements).
> > * @param areaCsvString The area CSV string. The CSV string is a flat
> > array in the
> > * form of: areaId, target, target parameters [, areaId, target,
> > target parameters...].
> > */
> > function ajaxUpdateAreas(areaCsvString) {
> > var areaArray = areaCsvString.split(",");
> > var numAreas = parseInt(areaArray.length / 3);
> > for (var i = 0; i < numAreas; i = i + 3) {
> > new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters:
> > areaArray[i + 2]});
> > }
>
> > }
>
> > I thought maybe the Ajax.Updater instances were erasing each other, so
> > I put them in array elements - but that didn''t fix the
problem.
>
> > I have confirmed the string argument passed to the function is
> > correct. I have confirmed each Ajax.Updater instance works
> > individually.
>
> > Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi,
FWIW, the fixed version in your follow-up post works fine on Windows
XP in the browsers I''ve tried it in: FF2, IE6, Safari 3, Opera 9.
Most likely an issue with the string you''re feeding in or the IDs of
the areas. My test string was:
"area1,test1.jsp,x=1,area2,test2.jsp,x=2,area3,test3.jsp,x=3"
...and the JSPs were along these lines:
<%
out.println("test1: x = " + request.getParameter("x"));
%>
...with these "areas" in my HTML page:
<div id=''area1''>area1</div>
<div id=''area2''>area2</div>
<div id=''area3''>area3</div>
All three areas updated correctly.
--
T.J. Crowder
tj / crowder software / com
On May 19, 9:06 pm, adrianc
<adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> Darrin,
>
> Thanks for pointing that out. The loop was correct originally, but it
> got mangled during debugging. The corrected code is:
>
> /** Update multiple areas (HTML container elements).
> * @param areaCsvString The area CSV string. The CSV string is a flat
> array in the
> * form of: areaId, target, target parameters [, areaId, target,
> target parameters...].
> */
> function ajaxUpdateAreas(areaCsvString) {
> var areaArray = areaCsvString.split(",");
> var numAreas = parseInt(areaArray.length / 3);
> for (var i = 0; i < numAreas * 3; i = i + 3) {
> new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters:
> areaArray[i + 2]});
> }
>
> }
>
> It still doesn''t work in IE.
>
> On May 19, 12:43 pm, darrin
<darrin.ho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > I can''t bring myself to tell you what''s wrong (hint:
it''s not
> > prototype), but try some simple debugging, like putting an
> > alert(''here'') before/after the Ajax.Updater call, to
make sure your
> > *loop* is actually working as you expect it to.
>
> > On May 19, 11:53 am, adrianc
<adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:
>
> > > I apologize if my question duplicates something asked before.
I''m new
> > > to JS programming and a search of this group didn''t
provide an answer.
>
> > > I''m trying to interface an existing application
framework to
> > > Prototype. I have a small set of JS functions the framework calls
to
> > > use the Prototype library.
>
> > > One of the functions creates multiple instances of Ajax.Updater
when a
> > > form is submitted. Only the first Ajax.Updater works, the rest
don''t
> > > do anything. Here is the code:
>
> > > /** Update multiple areas (HTML container elements).
> > > * @param areaCsvString The area CSV string. The CSV string is a
flat
> > > array in the
> > > * form of: areaId, target, target parameters [, areaId, target,
> > > target parameters...].
> > > */
> > > function ajaxUpdateAreas(areaCsvString) {
> > > var areaArray = areaCsvString.split(",");
> > > var numAreas = parseInt(areaArray.length / 3);
> > > for (var i = 0; i < numAreas; i = i + 3) {
> > > new Ajax.Updater(areaArray[i], areaArray[i + 1],
{parameters:
> > > areaArray[i + 2]});
> > > }
>
> > > }
>
> > > I thought maybe the Ajax.Updater instances were erasing each
other, so
> > > I put them in array elements - but that didn''t fix the
problem.
>
> > > I have confirmed the string argument passed to the function is
> > > correct. I have confirmed each Ajax.Updater instance works
> > > individually.
>
> > > Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---
TJ, Thank you for taking the time to look at this. I can''t get it to work in IE7. Your test confirms to me that there isn''t a problem with my logic, so I''ll take another look at the IDs being used. On May 20, 12:34 am, "T.J. Crowder" <tjcrow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > FWIW, the fixed version in your follow-up post works fine on Windows > XP in the browsers I''ve tried it in: FF2, IE6, Safari 3, Opera 9. > Most likely an issue with the string you''re feeding in or the IDs of > the areas. My test string was: > > "area1,test1.jsp,x=1,area2,test2.jsp,x=2,area3,test3.jsp,x=3" > > ...and the JSPs were along these lines: > > <% > out.println("test1: x = " + request.getParameter("x")); > %> > > ...with these "areas" in my HTML page: > > <div id=''area1''>area1</div> > <div id=''area2''>area2</div> > <div id=''area3''>area3</div> > > All three areas updated correctly. > -- > T.J. Crowder > tj / crowder software / com > > On May 19, 9:06 pm, adrianc <adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > Darrin, > > > Thanks for pointing that out. The loop was correct originally, but it > > got mangled during debugging. The corrected code is: > > > /** Update multiple areas (HTML container elements). > > * @param areaCsvString The area CSV string. The CSV string is a flat > > array in the > > * form of: areaId, target, target parameters [, areaId, target, > > target parameters...]. > > */ > > function ajaxUpdateAreas(areaCsvString) { > > var areaArray = areaCsvString.split(","); > > var numAreas = parseInt(areaArray.length / 3); > > for (var i = 0; i < numAreas * 3; i = i + 3) { > > new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters: > > areaArray[i + 2]}); > > } > > > } > > > It still doesn''t work in IE. > > > On May 19, 12:43 pm, darrin <darrin.ho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I can''t bring myself to tell you what''s wrong (hint: it''s not > > > prototype), but try some simple debugging, like putting an > > > alert(''here'') before/after the Ajax.Updater call, to make sure your > > > *loop* is actually working as you expect it to. > > > > On May 19, 11:53 am, adrianc <adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > > I apologize if my question duplicates something asked before. I''m new > > > > to JS programming and a search of this group didn''t provide an answer. > > > > > I''m trying to interface an existing application framework to > > > > Prototype. I have a small set of JS functions the framework calls to > > > > use the Prototype library. > > > > > One of the functions creates multiple instances of Ajax.Updater when a > > > > form is submitted. Only the first Ajax.Updater works, the rest don''t > > > > do anything. Here is the code: > > > > > /** Update multiple areas (HTML container elements). > > > > * @param areaCsvString The area CSV string. The CSV string is a flat > > > > array in the > > > > * form of: areaId, target, target parameters [, areaId, target, > > > > target parameters...]. > > > > */ > > > > function ajaxUpdateAreas(areaCsvString) { > > > > var areaArray = areaCsvString.split(","); > > > > var numAreas = parseInt(areaArray.length / 3); > > > > for (var i = 0; i < numAreas; i = i + 3) { > > > > new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters: > > > > areaArray[i + 2]}); > > > > } > > > > > } > > > > > I thought maybe the Ajax.Updater instances were erasing each other, so > > > > I put them in array elements - but that didn''t fix the problem. > > > > > I have confirmed the string argument passed to the function is > > > > correct. I have confirmed each Ajax.Updater instance works > > > > individually. > > > > > Any ideas?--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Okay, I solved it. IE7 won''t update a form element - the form must be wrapped with a div element and the ID of the div must be used for the update. Thanks everyone for your help! On May 20, 6:18 am, adrianc <adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> TJ, > > Thank you for taking the time to look at this. I can''t get it to work > in IE7. Your test confirms to me that there isn''t a problem with my > logic, so I''ll take another look at the IDs being used. > > On May 20, 12:34 am, "T.J. Crowder" <tjcrow...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > FWIW, the fixed version in your follow-up post works fine on Windows > > XP in the browsers I''ve tried it in: FF2, IE6, Safari 3, Opera 9. > > Most likely an issue with the string you''re feeding in or the IDs of > > the areas. My test string was: > > > "area1,test1.jsp,x=1,area2,test2.jsp,x=2,area3,test3.jsp,x=3" > > > ...and the JSPs were along these lines: > > > <% > > out.println("test1: x = " + request.getParameter("x")); > > %> > > > ...with these "areas" in my HTML page: > > > <div id=''area1''>area1</div> > > <div id=''area2''>area2</div> > > <div id=''area3''>area3</div> > > > All three areas updated correctly. > > -- > > T.J. Crowder > > tj / crowder software / com > > > On May 19, 9:06 pm, adrianc <adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > Darrin, > > > > Thanks for pointing that out. The loop was correct originally, but it > > > got mangled during debugging. The corrected code is: > > > > /** Update multiple areas (HTML container elements). > > > * @param areaCsvString The area CSV string. The CSV string is a flat > > > array in the > > > * form of: areaId, target, target parameters [, areaId, target, > > > target parameters...]. > > > */ > > > function ajaxUpdateAreas(areaCsvString) { > > > var areaArray = areaCsvString.split(","); > > > var numAreas = parseInt(areaArray.length / 3); > > > for (var i = 0; i < numAreas * 3; i = i + 3) { > > > new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters: > > > areaArray[i + 2]}); > > > } > > > > } > > > > It still doesn''t work in IE. > > > > On May 19, 12:43 pm, darrin <darrin.ho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I can''t bring myself to tell you what''s wrong (hint: it''s not > > > > prototype), but try some simple debugging, like putting an > > > > alert(''here'') before/after the Ajax.Updater call, to make sure your > > > > *loop* is actually working as you expect it to. > > > > > On May 19, 11:53 am, adrianc <adrian.c...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I apologize if my question duplicates something asked before. I''m new > > > > > to JS programming and a search of this group didn''t provide an answer. > > > > > > I''m trying to interface an existing application framework to > > > > > Prototype. I have a small set of JS functions the framework calls to > > > > > use the Prototype library. > > > > > > One of the functions creates multiple instances of Ajax.Updater when a > > > > > form is submitted. Only the first Ajax.Updater works, the rest don''t > > > > > do anything. Here is the code: > > > > > > /** Update multiple areas (HTML container elements). > > > > > * @param areaCsvString The area CSV string. The CSV string is a flat > > > > > array in the > > > > > * form of: areaId, target, target parameters [, areaId, target, > > > > > target parameters...]. > > > > > */ > > > > > function ajaxUpdateAreas(areaCsvString) { > > > > > var areaArray = areaCsvString.split(","); > > > > > var numAreas = parseInt(areaArray.length / 3); > > > > > for (var i = 0; i < numAreas; i = i + 3) { > > > > > new Ajax.Updater(areaArray[i], areaArray[i + 1], {parameters: > > > > > areaArray[i + 2]}); > > > > > } > > > > > > } > > > > > > I thought maybe the Ajax.Updater instances were erasing each other, so > > > > > I put them in array elements - but that didn''t fix the problem. > > > > > > I have confirmed the string argument passed to the function is > > > > > correct. I have confirmed each Ajax.Updater instance works > > > > > individually. > > > > > > Any ideas?--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---