Add a description of the submit button behavior to assets documentation #6701

Closed
Marmolin opened this Issue Jun 11, 2012 · 6 comments

4 participants

@Marmolin

Add a description of the submit button behavoir to assets documentation or some other doc as the current behavior does not agree with older (not html5) browsers, I think.
I thought I had a serious bug as the submit button did not react on mouseclicks in safari and IE when the required fields were empty altought it worked in firefox,
I googled for a solution but could not found any. However it worked when a did not required the jguery_ujs file and trying to find some bug in that file I found this very important information in the file comments

Required fields in rails.js

  • =========================== *
  • If any blank required inputs (required="required") are detected in the remote form, the whole form submission
  • is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission. *
  • The ajax:aborted:required event allows you to bind your own handler to inform the user of blank required inputs. *
  • !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
  • get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior. *
  • Ex:
  • $('form').live('ajax:aborted:required', function(event, elements){
  • // Returning false in this handler tells rails.js to submit the form anyway.
  • // The blank required inputs are passed to this function in elements.
  • return ! confirm("Would you like to submit the form with missing info?");
  • }); */

As that information cannot be found by googling I suggest that is is written down somewhere in the documentation e.g. in the assets guides

@njakobsen

I was stuck on the same issue. See rails/jquery-ujs#253. I'm not sure why this is the preferred behaviour, doesn't breaking compatibility with older browsers go against the whole "Unobtrusive JS" mantra?

@erichmenge

I must admit I was not aware of the new 'required' attribute in HTML5.

I think documenting this in the guides would be a good thing, but I can't think of an appropriate section. I don't believe it should go in the assets guides because it really has nothing to do with that.

Maybe a post to Stack Overflow so it shows up in search engines for other people that run into this behavior?

@Marmolin
@Marmolin
@erichmenge

@Marmolin Right, the assumption is that you'll present some sort of error message when the form isn't submitted.

What immediately comes to mind is posting it to something like stack overflow, or perhaps a blog post about it.

@rafaelfranca
Ruby on Rails member

I don't think that this is a Rails concern. This is a browser behavior. Closing this issue. Thank you to report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment