[solved] Re: [Dojo-interest] FormBind doesn't work - submit and click are never called

Jeff Chimene jchimene at gmail.com
Wed Jan 3 09:27:46 MST 2007


Mario Minati wrote:
> Mario Minati schrieb:
>> Jeff Chimene schrieb:
>>> Mario Minati wrote:
>>>> Hello @all,
>>>>
>>>> I try to submit a form, which is seated in a ContentPane, that is 
>>>> externally loaded (scriptscope activated).
>>>> I am testing and developing on Firefox 2.0 under Kubuntu Linux.
>>>>
>>>> The following code is executed in the form ContentPane.
>>>>
>>>>  <script type="text/javascript">
>>>>    function magicForm() {
>>>>        var x = new dojo.io.FormBind({
>>>>            formNode: dojo.byId('company_form'),
>>>>                          load: function(load, data, e) {
>>>>                dojo.debug("load called");
>>>>                dojo.byId('test').innerHTML = data;
>>>>            }
>>>>        });
>>>>    x.onSubmit = function(form) {
>>>>        dojo.byId("test").innerHTML = "Loading...";
>>>>        dojo.debug("onsubmit called");
>>>>        return true; // need this, otherwise form won't get sent!
>>>>    }
>>>>        dojo.debug("formBind created");
>>>>    }
>>>>              _container_.addOnLoad(magicForm);
>>>>  </script>
>>>>
>>>> After that comes a normal form with a submit button and no further 
>>>> javascript.
>>>>
>>>> If I press the submit button, the form is send as usual POST 
>>>> request and the whole page is replaced, no click or submit 
>>>> functions in the FormBind object are being called (I put some 
>>>> debuging output code in the dojo.js.)
>>>>
>>>> If I put in the following code:
>>>> <a 
>>>> href="javascript:dojo.byId('company_form_submit').click();">click</a>
>>>> I get an error message in the debug console like this:
>>>> Die Erlaubnis für die Methode XMLHTTPRequest.open wurde verweigert 
>>>> when calling listen$jointpoint$method on [object Object] with 
>>>> arguments [object Object]
>>>> and also none of the connected events (onsubmit, onclick) gets called.
>>>> I also don't understand why the open request is blocked as I am 
>>>> only operating on my local machine.
>>>>
>>>> Do you have any ideas where I can look in to solve these issues?
>>>>
>>>> Thanky you,
>>>> Mario
>>>
>>> I think you have to use the "x" object's click() method, not the 
>>> submit() method from the DOM.
>>>
>>> e.g.   x.form.company_form_submit.click()
>>>
>>> Cheers,
>>> jec
>> I just tried your idea with a closure that keeps x available. I think 
>> dojo is trying to submit the form, but I get again the message that 
>> XMLHttpRequest.open is not allowed. So it really looks like he's 
>> trying to send something to a different server, which is not 
>> possible, as everything is one server, but I don't know how to find 
>> out which url he's useing.
>>
>> Greets,
>> Mario
> I found the solution for the XMLHTTPRequest problem. I was catching 
> all click events on an a href and converting them, that also took 
> place for javascript links, so my pagecontainer tried to load a new 
> page with the javascript: url. :D
>
> I am still wondering why I cannot use the submit button (the whole 
> page is replaced) but I think that is a feature and not a bug.
>
Hi Mario,

Someone more experienced in Dojo than I will probably answer this 
correctly.

My $.02 is that the button press is being processed outside the Dojo 
event handling framework. The fundamental browser machinery handles the 
GET/POST, not Dojo; which end result is the undesired change in URL you 
observe.

The Dojo.book example uses the Dojo HTML parsing mechanism to set 
everything up, thus implicitly invoking the correct methods. Those who 
create or process forms dynamically must compensate by explicitly using 
the Dojo methods.


More information about the Dojo-interest mailing list