Hi,
I have implemented some RJS code and I have the same exact code in 2
different places. In one place I get the error “Element.update is not
a function” and the other place works fine. Any idea why this error is
coming? Breaking my head.
-Vinod
The Javascript generated looks like:
<div id="newpost">
<a href="#" onclick="try {
Element.update(“newpost”,
“<head>\n\n</head>\n<body>\n\n <form
action="/video/updatepost?topic_id=51&amp;parent_post_id=&amp;divname=newpost"
method="post" onsubmit="new Ajax.Updater(‘newpost’,
‘/video/updatepost?topic_id=51&parent_post_id=&divname=newpost’,
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(this)}); return
false;">\n\n<table width=100%>\n \n
<tr valign="top">\n <td>\n <span
style="font-family: Verdana, Arial, Sans-Serif; font-size:
10px">\n <textarea cols="40"
id="postmessage" name="postmessage"
rows="3"></textarea>\n </span>\n
</td>\n <td>\n <input id="commit"
name="commit" type="hidden"
value="Post" />\n <table>\n
<tr>\n <td>\n <input
id="SubmitPost_newpost" name="_commit"
type="submit" value="Post" />\n
</td>\n </tr>\n\n <tr>\n
<td>\n <input id="DiscardPost_newpost"
name="_commit" onclick="Form.getInputs(this.form,
null, ‘commit’)[0].value = ‘Discard’" type="submit"
value="Discard" />\n </td>\n
</tr>\n </table>\n </td>\n
</tr>\n</table>\n</form>\n</body>”);
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());
alert(‘Element.update("newpost",
"<head>\n\n</head>\n<body>\n\n <form
action=\"/video/updatepost?topic_id=51&amp;parent_post_id=&amp;divname=newpost\"
method=\“post\” onsubmit=\“new
Ajax.Updater(‘newpost’,
‘/video/updatepost?topic_id=51&parent_post_id=&divname=newpost’,
{asynchronous:true, evalScripts:true,
parameters:Form.serialize(this)}); return
false;\”>\n\n<table width=100%>\n \n
<tr valign=\“top\”>\n <td>\n <span
style=\“font-family: Verdana, Arial, Sans-Serif; font-size:
10px\”>\n <textarea cols=\“40\”
id=\“postmessage\” name=\“postmessage\”
rows=\“3\”></textarea>\n </span>\n
</td>\n <td>\n <input id=\“commit\”
name=\“commit\” type=\“hidden\”
value=\“Post\” />\n <table>\n
<tr>\n <td>\n <input
id=\“SubmitPost_newpost\” name=\"_commit\"
type=\“submit\” value=\“Post\” />\n
</td>\n </tr>\n\n <tr>\n
<td>\n <input
id=\“DiscardPost_newpost\” name=\"_commit\"
onclick=\“Form.getInputs(this.form, null, ‘commit’)[0].value =
‘Discard’\” type=\“submit\”
value=\“Discard\” />\n </td>\n
</tr>\n </table>\n </td>\n
</tr>\n</table>\n</form>\n</body>");’);
throw e }; return false;">Post a new comment
I simplified the JS code to:
<div id="newpost">
<a href="#" onclick="try {
Element.update(‘newpost’, ‘hello’);
} catch (e) { alert(‘RJS error:\n\n’ + e.toString());
alert(‘Element.update("newpost", "hello");’);
throw e }; return false;">Post
and still the error
Figured it out… Forgot to add the prototype.js