[Dojo-interest] form submit in ContentPanes

Christian Thies christian.thies at go-community.de
Thu Feb 8 01:18:58 MST 2007


Ok, I've found a solution - thanks to Ryan!

I've bound 'onLoad="display_init();"' to my ContentPane, and defined:
<code>
            function display_init() {
                var allforms = document.getElementsByTagName("form");
                var i;
                var x;
                var form;
                for(i=0; i<allforms.length; i++)
                {
                    form = allforms[i];
                    //alert(form.name);
                   
                    x = new dojo.io.FormBind({
                        formNode: form,
                        load: function(type, data, evt) {
                            //display results data here
                            display.setContent(data);
                        },
                        error: function(t, form) {
                           //handle errors from server here
                        }
                    });
               
                     x.onSubmit = function(form) {
                        //do your validation here
                        return true; // needed to submit form
                    }
                }
            }
</code>

I've read in this list, that 'form.submit();'-calls arent catched by 
dojo's FormBind :(
But there's a workaround:
Define an invisible button:
<input type="submit" name="findItemGroup" id="goforit" style="display: 
none;">

and change
'form[0].submit();' to 'getElementById("goforit").click();'

It works :)

cheers,
Christian

Christian Thies schrieb:
> Hi everybody!
>
> I'm trying to submit forms within a dynamically loaded ContentPane, like
> ...
> <div id="dw_content" dojoType="ContentPane" widgetId="display" 
> layoutAlign="client" cacheContent="false" 
> href="/_framesets/start_content.html" preventCache="true" 
> useCache="false" refreshOnShow="true" executeScripts="true">
> </div>
> ...
>
> After loading another url to that pane via 
> "dojo.widget.byId('display').setUrl('/commerce/item_group_content.html');" 
> I wonder how to manage submitting the form of 
> "/commerce/item_group_content.html" such that the results are showing 
> in "display" again.
> ...
> <form name="o_ShopItem" action="/commerce/item_group_content.html" 
> method="post">
> ...
>
> I've managed to catch the "onsubmit" event - if some <input 
> type="submit"> is pressed:
> ...
>                dojo.event.connect(display.domNode, "onsubmit", 
> 'relaySubmits');
> ...
>            function relaySubmits(evt){
>                var form = evt.target;
>                alert("submit "+form.name);
>            }
> ...
> But if the form is submitted by a javascript call 
> "document.forms[0].submit();" I don't catch anything at all :(
>
> So, how can I catch "submit();"-calls, and how is it going further on? 
> Have I to loop over all elements of the form and concatenate the url 
> myself to finally "display.setUrl(url)"?
>
> I sense that there is a "cheaper" way ...
>
> Thanks,
> Christian
>
>
>

-- 
Anwendungsentwicklung

BLACKBIT interactive GmbH | BLACKBIT Viani GmbH
Ernst-Ruhstrat-Str. 6 - D-37079 Goettingen

tel.: +49-551-50675-50 - fax.: +49-551-50675-55
email: christian.thies at go-community.de

Klassische Werbung und Online-Marketing: http://www.blackbit.de
Software für Online-Marketing: http://www.go-community.de



More information about the Dojo-interest mailing list