Fixing GET forms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fixing GET forms

hernanmd
Hello guys,

I've noticed you cannot have working forms with GET method with current iliadJs. The problem is in the current version a parameter "post" is hardcoded when calling evaluateAction() and "get" is set only when processing anchors, i.e. evaluateAnchorAction().

As a consequence is not easy to implement forms with GET buttons for example.

The current fix I found is retrieving the user specified form type:

    function evaluateFormAction(form) {
        var actionUrl = getFormActionUrl(form);
        var data = jQuery(form).serialize();
        var method = jQuery(form).attr("method");
        evaluateAction(actionUrl, method, data);
    }

Instead of the hardcoded "post"

    function evaluateFormAction(form) {
        var actionUrl = getFormActionUrl(form);
        var data = jQuery(form).serialize();
        evaluateAction(actionUrl, "post", data);
    }

This fix can solve problems with sending attachments from server-side. But is incomplete, because some strange logic using ILUrlBuilder actionKey when retrieving an ILRequest actions... this is, if no _action is found, then actionField gets nil and then callbacks are not processed.

So, _action is set only to anchors, not to forms. So the challenge could be to have something like:

    function hasActionUrl(anchor) {
        if(anchor && jQuery(anchor).attr(''href'')) {
            return (/_action?=(.*)$/).test(jQuery(anchor).attr(''href''));
        }
    }

in

    function getFormActionUrl(form) {
        return jQuery(form).attr(''action'');
    }

Thinking out loud if we prepend "_action" in getForActionUrl() response that would have undesired collateral consequences?

Cheers,

Hernán

--
You received this message because you are subscribed to the Google Groups "Iliad project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...