Forum OpenACS Development: Ajax Helper load error

Posted by Eduardo Santos on
Hi all,

I'm facing a little trouble in putting ajaxhelper to work in my install upgrade. I'm using oacs-5-3 with the acs-integration-procs.tcl, head-procs.tcl and all the template files in www directory in head versions, but I can't make my old ajax work. I'm trying to run a single command, wich is:

set js_update_user_select [ah::ajaxupdate \
-container "tech_select" \
-url "search-users" \
-options "encoding:'UTF-8'" \
-pars "Form.serialize('catalog')"]

In the form definition part (using ad_form) I have:

{tech_responsible:text(text) {label "[_ catalog.Tech_responsible]"} {html {onKeyUp "$js_update_user_select document.getElementById('tech_select').style.visibility='visible';" autocomplete "off"}} {after_html "<div id=\"tech_select\"></div>"} }

When I try to load the page, firebug shows me the following error:

uncaught exception: requires the Prototype JavaScript framework >= 1.5.1

I've checked the files ajaxhelper/www/resources/scriptaculous/scriptaculous.js and ajaxhelper/www/resources/prototype/prototype.js and they seem to be in right version.

When I type something in the field so the ajax could search, I have the following error:

$(form) has no properties
return $A($(form).getElementsByTagName('*')).inject([],...

Can anybody help me on this?

2: Re: Ajax Helper load error (response to 1)
Posted by Hamilton Chua on
I updated blank-master.tcl in ajaxhelper/www/docs in CVS HEAD.

Scriptaculous depends on prototype being loaded first so I had to modify the template::head add_script function to accept an order parameter which is an integer that will be used to sort the javascript sources. This gives developers control over which javascript sources get loaded first

Please update your blank-master.tcl and let me know if the error still occurs.

Thanks !

3: Re: Ajax Helper load error (response to 2)
Posted by Eduardo Santos on
Hi Hamilton,

Thank you for the answer. I can understand know a little bit more about the new templates, but I guess we have a major problem here.

I've managed to put your new blank-master to work, but the dotlrn toolbar and the ds where being repeated forever. Checking your code I could see that blank-master.adp has the following lines:

list name="header">
list name="footer">

This list tag makes no sense to me, and it was making the header and footer to be repeated. I've removed this tag and the page loaded OK. The new lines where like this:


Anyway, my Ajax still don't work. I'm facing this error right now:

$(form) has no properties
getElements("catalog")prototype.js (line 2649)
serialize("catalog", undefined)prototype.js (line 2645)
onkeyup(keyup charCode=0, keyCode=65)add-edit (line 1)
[Break on this error] return $A($(form).getElementsByTagName('*')).inject([],

Firebug tells me that this error comes from the prototype.js file in line 2649. My JavaScript knowledge is poor, but can we use dolar quoting to indicate that it's a var (I mean $var) as we do in TCL? Do you think this issue has something to do with this error or are we facing another problem?

I still have another concern. Checking out HEAD version of OpenACS template files, I can see your files and OpenACS files are very different and it affects the entire system. Take a look at this diff (I know it's a little messy, but you can get my point from there):

There are a lot of vars in OpenACS version wich are not in your file and your files also have big differences, mostly in blank-master.tcl. So, my doubt is: wich one should I use? It seems to me that your file has some problems about Xinha loading, but I can't say this for sure.

There's also a big difference in head-procs.tcl and acs-integration-procs.tcl (from the files in ajaxhelper and the other ones in acs-templating/tcl HEAD). Wich ones are the best for use? I guess I'm a little lost here.

Thank you very much for your help and all your work on this.

4: Re: Ajax Helper load error (response to 3)
Posted by Hamilton Chua on
Hi Eduardo,

I took some time to check the changes on OpenACS head and you're absolutely right, the files I included in my www/docs are now outdated. My bad for not keeping up :-)

I included copies of those files in www/docs because at the time template::head wasn't in CVS head yet but now they are so I'll be removing them on my next update. I will update the docs too.

Please use the ones from cvs head.

I just committed a change in head-procs.tcl which solves the error about prototype being required, so please get a fresh copy of head-procs.tcl from cvs head.

Now about that javascript error.

Do you have an id for your form ?

The error indicates that it can't find the form element.

Maybe instead of $(form), try using $("formid") where formid is the id you give your form.

Your form should look like &lt form id="formid" ... &gt

If you're using ad_form I believe you can add it in the html parameter like -html {id "formid"}

Thanks for trying out ajaxhelper and do let me know if this helped.



5: Re: Ajax Helper load error (response to 4)
Posted by Eduardo Santos on
Hi Hamilton,

Sorry about the delay. I had to perform a lot of tests before I'm sure everithing is working.

I'm using now HEAD versions of all the files (the whole master stuff and the templating procs) and it seems to be working now. However, I had to manually setup the form id using the html id. It seems to me that ad_form is not parsing the right DOM information to the form. I uses a hidden input named form:id, and firefox doesn't see that as the form id.

Maybe someone need to change the ad_form API to improve DOM integration?

Thank you very much for your help. Everything is working now.