AjaxUpdateContainer function not defined [SOLVED]
AjaxUpdateContainer function not defined [SOLVED]
- Subject: AjaxUpdateContainer function not defined [SOLVED]
- From: Marcos Trejo Munguia <email@hidden>
- Date: Tue, 19 Sep 2006 11:23:11 -0500
Hi List,
I found the following on this issue,
If your server logic returns JavaScript code along with HTML markup, the Ajax.Updater object can evaluate that JavaScript code. To get the object to treat the response as JavaScript, you simply add evalScripts: true; to the list of properties in the last argument of the object constructor. But there's a caveat. Those script blocks will not be added to the page's script. As the option name evalScripts suggests, the scripts will be evaluated. What's the difference, you may ask? Lets assume the requested URL returns something like this:
<script language="javascript" type="text/javascript">
function sayHi(){
alert('Hi');
}
</script>
<input type=button value="Click Me" onclick="sayHi()">
In case you've tried it before, you know it doesn't work. The reason is that the script block will be evaluated, and evaluating a script like the above will not create a function named sayHi. It will do nothing. To create this function we need to change our script to create the function. See below.
<script language="javascript" type="text/javascript">
sayHi = function(){ alert('Hi'); };
</script>
<input type=button value="Click Me" onclick="sayHi()">
Note that in the previous example we did not use the var keyword to declare the variable. Doing so would have created a function object that would be local to the script block (at least in IE). Without the var keyword the function object is scoped to the window, which is our intent.
http://www.sergiopereira.com/articles/prototype.js.html#UsingAjaxUpdater
So the problem is that Ajax.framework generates the functionUpdate() like the first example.
Cheers
On Sep 14, 2006, at 7:04 PM, Marcos Trejo Munguia wrote:
Hi List,
I have a big problem with AjaxUpdateContainer, I have an AjaxDroppable matrix, for every droppable object in the matrix I have an AjaxUpdateContainer inside. The id of the container is generated with the row and column numbers, something like _00, _01, _02, etc. I added the underscore to be able to call the function <id>Update() every time that something is dropped inside an AjaxDroppable, so the onDrop look like this "function(element, droppableElement) { _[row][column]Update(); }" for each AjaxDroppable, the problem comes when you change the number of rows or columns in the matrix, the initial size of the matrix is 4x4, if I change the number of rows to 6 for example, when I drop something in rows 5 or 6 I get the next JavaScript Error: _50Update() is not defined.
I would appreciate any help.
Thanks in advanced.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden