Skip to content

Add multi-button form support#18

Closed
NickClark wants to merge 1 commit intorails:masterfrom
NickClark:master
Closed

Add multi-button form support#18
NickClark wants to merge 1 commit intorails:masterfrom
NickClark:master

Conversation

@NickClark
Copy link

I have modified the form submission function callRemote to allow a button to be passed in and be submitted with the form data. I also added the a live event call that adds a 'click' event handler to each submit button in a form, passing to callRemote that button as an argument. The submit event has been left intact. Only one or the other should fire since the event is kept from bubbling up. I have not had time to write a test and also am not familiar with the test framework.

@neerajsingh0101
Copy link

Can you kill http://github.com/NickClark/jquery-ujs/commit/254d5f5f7a553904d7d4841e4532d05a620c697f .

Also please merge http://github.com/NickClark/jquery-ujs/commit/c6f00a10de753c1fb58a9f187460666c4d52835c and http://github.com/NickClark/jquery-ujs/commit/71ff00b85ac457ec2e3b9262e7a2de7fb5426b53 into a single commit.

If possible add a test. You can look at existing set of tests to get an idea on how to write them.

Let me know if you have any question.

@NickClark
Copy link
Author

Also part of this commit: bundler complains about a source, so I added one.

@neerajsingh0101
Copy link

Rather than passing $(this) to $(this).callRemote($(this)), How about passing e. And then in the method call you can do e.target. This will work not only for button but also for submit elements.

Also here callRemote: function (button) , the variable name is button. But it could be button or any input element. I would suggest that let's make it generic. Pseuedo code is here.

var target = e.target;
var name = target.attr('name');
if (name) {
 data.push({name: name, value: target.attr('value')});
}

Let me know your thoughts.

Notice that in your test you are attaching an input element and not a button. That's the main reason why I want to avoid calling variable 'button'.

Thanks.

@neerajsingh0101
Copy link

If you are having any difficulty with existing pull request then create a new one. Also if you are creating a new pull request then please split commit related to gemfile in a different commit.

Thanks

@NickClark
Copy link
Author

I should have a fix this week. Actually, I thought I had it fixed this evening (maybe still do) but all of a sudden I can't get the test suite to pass, on my fork, nor on a fresh clone of the project. Ill update the pull request once I get the tests passing.

@neerajsingh0101
Copy link

If you need any help then lemme know.

@aarona
Copy link

aarona commented Nov 11, 2010

Nick, good job. I forked this project specifically to add this feature, I'm glad someone else has thought of this.

@NickClark
Copy link
Author

This should be it. Let me know if there is something else you notice or think should be done. Im glad you caught the button vs input issue, I hadn't though of that.

@neerajsingh0101
Copy link

On a quick glance code looks good to me. I will dig deep into code today or tomorrow and will provide feedback.

Thank you.

@neerajsingh0101
Copy link

Can you rebase your code against master. Master has changed a lot in the last 2/3 days.

Thanks.

@NickClark
Copy link
Author

Done! I must say, Iam amazed at githubs ability to track a pull request. Despite all the changes from me doing forced push's and the commit hash changing, it always updates this pull request properly.

@neerajsingh0101
Copy link

Just want to let you know that the tests you wrote pass for jQuery 1.4.4 but they fail for jQuery 1.4.3 . If you run the test then at the top you will see link for 1.4.3 click on that and you will see the failure.

Fix is easy and I am applying that.

@neerajsingh0101
Copy link

Actually your test is failing only on Firefox for jQuery 1.4.3 and that also randomly. I will have to look closely what's going on.

@NickClark
Copy link
Author

Thanks for catching that. I was aware that I could test the different versions and looking at it again in my browsers doesn't show a failure. Which browser did it fail for you in?

@neerajsingh0101
Copy link

If I fix the test for jQuery 1.4.3 in FF then it fails for jQuery 1.4.4 in FF. Not sure what's so special about FF. Tests work fine in chrome.

Will come back to this this issue in a couple of days. If you can find more info then do share.

Thanks

@neerajsingh0101
Copy link

It is failing for Firefox with jQuery 1.4.3 .

@neerajsingh0101
Copy link

I am closing this ticket since the tests are still failing for me.

I would suggest to split the functionality in two different pull requests. In the first scenario lets just handle two submit buttons. In the next iteration we will worry about buttons.

Hopefully when we take incremental steps then we can make tests pass.

Since new pull requests will be made I am closing this ticket.

@harrism
Copy link

harrism commented May 12, 2011

Hello Neeraj and Nick,

I know this is an old, closed request, but I'm running into the same issue that Nick was trying to fix -- I have a form_for :remote, using jquery-rails, with multiple submit buttons, and it doesn't work. Is there any plan to fix this?

Thanks!
Mark

@neerajsingh0101
Copy link

I will take a look over the weekend. Or may be Steve can reply before I have a chance.

@harrism
Copy link

harrism commented May 12, 2011

Thanks Neeraj! For now I've hacked my local copy using Nick Clark's
approach -- it works in my code even if it doesn't pass tests. I'd
like to have a more official fix though.

Cheers,
Mark

On Thu, May 12, 2011 at 3:51 PM, neerajdotname
reply@reply.github.com
wrote:

I will take a look over the weekend. Or may be Steve can reply before I have a chance.

Reply to this email directly or view it on GitHub:
#18 (comment)

@neerajsingh0101
Copy link

Before you know it Steve will have an answer. He is on it. :-)

@JangoSteve
Copy link
Member

Hey guys, sorry I've gotten really backed up this week. I'll be able to take a look at this this weekend I think. Is there any chance you can open a new issue linking to this one, just so I don't forget?

@JangoSteve
Copy link
Member

Actually are you guys hoping some form of the code in this pull request will get pulled in, or are you hoping for a new take on the problem, which may be easier with the new code-base? If the former, we can just re-open this pull request. If the latter, then maybe we can open that new ticket.

@harrism
Copy link

harrism commented May 16, 2011

HI Steve,

I don't have any need for the code in the pull request to get pulled in, I just need multiple submit buttons in an ajax form to be differentiable inside the controller actions they invoke. I will open a new issue.

@harrism
Copy link

harrism commented May 16, 2011

I created a new issue: https://rails.lighthouseapp.com/projects/8994/tickets/6001

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants