Call partial by jquery

Hi Guys,
Sb could help me in this problem?
I have an partial that I pass some parameters…
I need to create many partials by click event of a link, How can I do
that?

I tried to do like this way
But it does’nt work…

$("#addContactLink").bind(“click”,
function(){
$("#partialtestdiv").append("<%=render
:partial=>‘shared/user_contacts’,:locals=>{:f=>f},:object=>resource.user_contacts
%>");
}
);

Bruno M.

On Fri, Dec 23, 2011 at 12:01 PM, Bruno M. [email protected]
wrote:

Hi Guys,
Sb could help me in this problem?
I have an partial that I pass some parameters…
I need to create many partials by click event of a link, How can I do that?

I tried to do like this way
But it does’nt work…

Do you get an error, or just no text in partialtestdiv?


You received this message because you are subscribed to the Google G.
“Ruby on Rails: Talk” group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Greg A.
http://twitter.com/akinsgre

No errors appears just a pure html is inserted in div:
<%=render
:partial=>‘shared/user_contacts’,:locals=>{:f=>f},:object=>resource.user_contacts
%>

the html is similar of the inserted partial in div

Hmmmm…
Ok, I will try do this using an ajax call…
But How can I pass object references using an ajax call? Is it possible
in
rails or I need pass object attributes by JSON?
Thx :smiley:

On Fri, Dec 23, 2011 at 11:12 AM, Bruno M. [email protected]
wrote:

Hmmmm…
Ok, I will try do this using an ajax call…
But How can I pass object references using an ajax call? Is it possible in
rails or I need pass object attributes by JSON?

I believe that’s what the ‘data’ argument of the .load function is
supposed to be used for. Make a simple test using a string and see
what you get in the params hash on the server.

Best regards,
Bill

HI Bruno,

On Fri, Dec 23, 2011 at 11:01 AM, Bruno M. [email protected]
wrote:

$("#partialtestdiv").append("<%=render

:partial=>‘shared/user_contacts’,:locals=>{:f=>f},:object=>resource.user_contacts

%>");
}
);

The onclick is executing in the browser so you’re not going to be able
to use erb in it. You’ll want to make an ajax call (.load is a handy
shortcut for this) to the server where you can render the partial
using erb to get the html you need returned.

HTH,
Bill

Ok!!
I will take a look better in these parameters.
I’m using default chrome developers js debug. Is Firebug better?
thx for the help ;D

On Fri, Dec 23, 2011 at 12:08 PM, Bruno M. [email protected]
wrote:

Ok!!
I will take a look better in these parameters.
I’m using default chrome developers js debug. IsFirebug better?
thx for the help ;D

I do all my dev work in Firefox because of the tools. I hear Chrome
is catching up but don’t have any experience there yet.

Bill

On Fri, Dec 23, 2011 at 11:19 AM, Bill W. [email protected]
wrote:

On Fri, Dec 23, 2011 at 11:12 AM, Bruno M. [email protected] wrote:

Hmmmm…
Ok, I will try do this using an ajax call…
But How can I pass object references using an ajax call? Is it possible in
rails or I need pass object attributes by JSON?

I believe that’s what the ‘data’ argument of the .load function is
supposed to be used for. Make a simple test using a string and see
what you get in the params hash on the server.

If you’re not already using them, I find both the Firebug and Live
HTTP Headers plug-ins indispensable for exploring ajax calls.

Bill