问题
The following code used to function without attempting to render a new template with jQuery verion 1.6. I installed jQuery 1.6.1 and now a radio button click results in an attempt to render a new page.
FYI, the form was submitted on each click because quite a few clients would complete part of the questions, close the browser and expect their work to be there when they came back to finish. If there is a better way, I'd love to know it.
in the application.js on development machine:
$('.submittable').live
('change', function()
{
$(this).parents('form:first').submit();
return false;
}
);
Again, this works in jQuery 1.6 but not 1.6.1. I used this tutorial as a guide.
Any help is appreciated.
UPDATE: continuation of this issue here.
回答1:
Try:
$('.submittable').live('change', function(event) {
event.preventDefault();
$(this).parents('form:first').submit();
return false;
});
回答2:
Look at your linear chain of events... You are submitting the form every time and then trying to return false...perhaps you are looking for something like this:
$('.submittable').live('change', function(){
if( /some condition/ ){
$(this).parents('form:first').submit();
} else {
return false;
}
});
回答3:
The problem was one version of jQuery on the production machine and another on the development machine. We changed from 1.6 full to 1.6.1 min on the development machine. When i changed it back the problem disappeared. Thanks for all your help guys. Kudos to thedaian. I'll switch the answer over to him if he posts.
来源:https://stackoverflow.com/questions/6192060/jquery-return-false-works-in-version-1-6-but-not-1-6-1-rails-3