Hi Guys,
I hava a link that send via ajax some data. In this link I want to insert
some params... How can I do this?

thx
:D
Bruno Meira

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Bruno Meira at Dec 26, 2011 at 10:53 pm
    I'm using link_to helper

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Rifki Fauzi at Dec 27, 2011 at 8:37 am
    unless u add a params you can use an untrobusive javasscript.. something
    like this:

    link_to "something", :onclick => "someFunc(current_user.email)"

    function someFunc(email){
    $.ajax({
    url: '/my_url',
    type: 'POST',
    data: {email: email}, // parameter
    success: function(data, textStatus, xhr) {
    // success callback
    },
    error: function (data, textStatus, xhr) {
    // error callback
    }
    }

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Alex Mercer at Dec 27, 2011 at 11:31 am
    Rifki, just a little fix:
    link_to "something", :onclick => "someFunc(<= current_user.email %>)"
    On Dec 27, 10:36 am, Rifki Fauzi wrote:
    unless u add a params you can use an untrobusive javasscript.. something
    like this:

    link_to "something", :onclick => "someFunc(current_user.email)"

    function someFunc(email){
    $.ajax({
    url: '/my_url',
    type: 'POST',
    data: {email:  email}, // parameter
    success: function(data, textStatus, xhr) {
    // success callback
    },
    error: function (data, textStatus, xhr) {
    // error callback
    }

    }

    --
    Posted viahttp://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Alex Mercer at Dec 27, 2011 at 11:32 am
    And again.. damn.. i need to get some sleep =)

    link_to "something", :onclick => "someFunc(<%= current_user.email
    %>)"
    On Dec 27, 1:30 pm, Alex Mercer wrote:
    Rifki, just a little fix:
    link_to "something", :onclick => "someFunc(<= current_user.email %>)"

    On Dec 27, 10:36 am, Rifki Fauzi wrote:






    unless u add a params you can use an untrobusive javasscript.. something
    like this:
    link_to "something", :onclick => "someFunc(current_user.email)"
    function someFunc(email){
    $.ajax({
    url: '/my_url',
    type: 'POST',
    data: {email:  email}, // parameter
    success: function(data, textStatus, xhr) {
    // success callback
    },
    error: function (data, textStatus, xhr) {
    // error callback
    }
    }
    --
    Posted viahttp://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Bruno Meira at Dec 27, 2011 at 1:59 pm
    I found the answer....
    I fixed this problem using:

    $("#addContactsToUser").bind("ajax:before", function()
    {
    $(this).data('params', { test: 'bar' });
    });

    As you can notice I insert post params before send my request.
    This solution works ok ;D
    Thx

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 26, '11 at 10:53p
activeDec 27, '11 at 1:59p
posts6
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase