2009年2月10日星期二

Re: [fw-mvc] Dojo Form Problem

> <matthew@zend.com> wrote:
>> You need to bind the form's onSubmit action to first validate prior to
>> submission. You can do that fairly easily:
>>
>> dojo.connect(dijit.byId("<FORMIDHERE>"), "onSubmit", function(e){
>> e.preventDefault();
>> var form = dijit.byId("<FORMIDHERE>");
>> if (form.isValid()) {
>> form.submit();
>> return true;
>> }
>> return false;
>> });
>>
>> You can add that to the form via a decorator, or add this as a
>> dojo.addOnLoad event for the page.

Should adding this to the action controller work? I tried, it didn't,
and I'm not sure why - dojo is being loaded as the first thing in the
header.


$this->view->headScript()->captureStart();
?>
dojo.addOnLoad(
function(){
dojo.connect(dijit.byId("mileagelog"), "onSubmit", function(e){
e.preventDefault();
var form = dijit.byId("mileagelog");
if (form.isValid()) {
form.submit();
return true;
}
return false;
})
}
);

<?php
$this->view->headScript()->captureEnd();

没有评论: