2011年2月11日星期五

[fw-mvc] From using Zend_Dojo_Form causes javascript error

I have a form that extends Zend_Dojo_Form. When an Editor dijit is
used, some generated addOnLoad code is output by ZF. This bit of code
keeps erroring out and stops javascript execution.

According to firebug, the error is:

elementNode is null
[Break On This Error] while (elementNode.nodeName.toLowerCase() != 'form') {


The html source of the editors with plugins list removed for clarity:

<input id="summary" name="summary" value="" type="hidden" /><div
trim="1" jsId="summaryEditor" id="summary-Editor" inheritWidth="1"
height="100px" required="true" dojoType="dijit.Editor"></div>
<noscript><textarea name="summary" id="summary-Editor" trim="1"
jsId="summaryEditor" inheritWidth="1" height="100px" plugins="
required="true" dojoType="dijit.Editor" rows="24"
cols="80"></textarea></noscript>

<input id="content" name="content" value="" type="hidden" /><div
trim="1" jsId="contentEditor" id="content-Editor" inheritWidth="1"
height="500px" required="true" dojoType="dijit.Editor"></div>
<noscript><textarea name="content" id="content-Editor" trim="1"
jsId="contentEditor" inheritWidth="1" height="500px" required="true"
dojoType="dijit.Editor" rows="24" cols="80"></textarea></noscript>

The addOnLoad code:

dojo.addOnLoad(function() {
var form = zend.findParentForm(dojo.byId('summary'));
dojo.connect(form, 'submit', function(e) {
dojo.byId('summary').value =
dijit.byId('summary-Editor').getValue(false);
});
});
dojo.addOnLoad(function() {
var form = zend.findParentForm(dojo.byId('content'));
dojo.connect(form, 'submit', function(e) {
dojo.byId('content').value =
dijit.byId('content-Editor').getValue(false);
});
});
if (zend == undefined) {
var zend = {};
}
zend.findParentForm = function(elementNode) {
while (elementNode.nodeName.toLowerCase() != 'form') {
elementNode = elementNode.parentNode;
}
return elementNode;
};

All of this seems to me to look good. In fact, this is so puzzling
because this is the first time I've ever encountered this error. I
can't find any namespace collisions or anything that would prevent
this code from executing properly. Any ideas on what could be causing
this error?

--regards,
nathan

没有评论: