my bad. I was working on an app that had an old web2py.js. seems definitely 
some bad idea to exclude buttons with no name. 

On Saturday, November 8, 2014 5:32:09 PM UTC+1, Anthony wrote:
>
> In web2py.js, we have:
>
>     formInputClickSelector: 'input[type=submit]:not([name]), 
> input[type=image]:not([name]), button[type=submit]:not([name]), 
> button:not([type]):not([name])'
>
> Doesn't that only select buttons with no names? But in this case, we 
> specifically want to capture buttons with names.
>
> Anthony
>
> On Friday, November 7, 2014 6:24:35 PM UTC-5, Niphlod wrote:
>>
>> ah shoot, submit can also be triggered pressing "enter"...
>> guess we're stuck with this then...... opinions ? (if everybody agrees 
>> I'll send a PR)
>>
>> trap_form: function (action, target) {
>>       /* traps any LOADed form */
>>       $('#' + target + ' form').each(function (i) {
>>         var form = $(this);
>>         form.attr('data-w2p_target', target);
>>         if(!form.hasClass('no_trap')) {
>>           form.submit(function (e) {
>>             console.log(form.serialize())
>>             web2py.disableElement(form.find(web2py.formInputClickSelector
>> ));
>>             web2py.hide_flash();
>>             web2py.ajax_page('post', action, form.serialize(), target, 
>> form);
>>             e.preventDefault();
>>           });
>>           /* simulating behaviour of non-ajax forms, where the click on 
>> a submit
>>           button also submits its name and value */
>>           form.on('click', web2py.formInputClickSelector, function (e) {
>>             e.preventDefault();
>>             var input_name = $(this).attr('name');
>>             if (input_name != undefined) {
>>               $('<input type="hidden" />').attr('name', input_name)
>>               .attr('value', $(this).val()).appendTo(form)
>>             }
>>             form.trigger('submit');
>>           })
>>         }
>>       });
>>     },
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to