Skip to content

Maybe interesting to include#88

Closed
butsjoh wants to merge 3 commits intorails:masterfrom
younited:master
Closed

Maybe interesting to include#88
butsjoh wants to merge 3 commits intorails:masterfrom
younited:master

Conversation

@butsjoh
Copy link

@butsjoh butsjoh commented Feb 2, 2011

Hey,

First of all i want to inform that i don't have created tests for the changes i made but i will try to if i understand how it works.

The pull request contains 2 fixes i encountered while using rails.js.

  1. If you use the data-disable-with functionality that will display a loading message on a button if you submit a form you have to know that there is an issue with this in ie7. Because in ie when you disabled a button it won't fire the submit event anymore causing not form to submit at all. That why i removed setting the disabled attribute and implemented a global submitted value on the form which will also prevent pressing the button twice what disabled also does.

  2. As far of the required fields i don't think it's a good idea to enable this by default because one might assume you don't want it. I think the default should be that it's disabled.

Would like to have feedback if the above comments are not valid.

thnx

data-disabled-with because it will not submit your
forms in ie7.
you press enter instead of clicking the button
@butsjoh
Copy link
Author

butsjoh commented Feb 3, 2011

I also added another fix in my fork that will fix an issue in ie where you press "ENTER" on an input. Without the fix it didn't want to submit the form. IE has some weird event calling when you press enter:

  • when you press the submit button: button event gets called, form submit event gets called
  • when you press "ENTER": submit event gets called, button event gets called, submit event gets called

It's really weird and because i implemented the double submit it didn't want to proceed, hence the fix.

@mislav
Copy link
Member

mislav commented Feb 3, 2011

I don't think I'll pull this.

Regarding "required" fields: if you can put together feature detection that only enables this behavior in browsers that don't submit forms with missing values (i.e. Opera for now), I would gladly disable it for other browsers. However, since such feature detection doesn't seem possible, I have to enable it in all browsers. Yes, this means that remote forms will not be sent over Ajax if required values are missing. As for regular forms, they're left intact.

Regarding disabling form buttons and IE: this is an IE bug that I need to work around. I don't think a good workaround is implementing this feature the way you did. First, you completely disabled the possibility that any form could be submitted more than once, forgetting that some use-cases might required "remote" forms to be submitted multiple times (with users possibly entering different values each time, like a live chat message. Second, unlike the disabled submit buttons, your solution doesn't provide any UI hint that the button is inactive. A disabled submit button is grayed out by default and can be further styled with CSS to communicate "this is not clickable".

I think I have a simple solution for IE and disabling buttons, but I could never write a proper test because jQuery has a bug with triggering form submit via button click (it doesn't emulate it correctly).

@butsjoh
Copy link
Author

butsjoh commented Feb 4, 2011

Thnx for the reply :)

About the form submission, i left the part out where you enable the form again by default. In the ajax:complete you could enable your form again by set form.submitted to false. I know this solution is not immediately clear but in our case we don't want double submissions.

I understand that removing disable is not the best solution ever but it really prevented use from submitting the form in ie (it just didn't work).

I look forward to other solutions for the problems we encountered and this was my own solution for the problems we had.

@JangoSteve
Copy link
Member

If anyone comes across this (googling or whatever), I added the IE ENTER button problem to the Wiki with a solution.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants