# Calling a jQuery function from RJS/onclick

**URL:** <https://www.ruby-forum.com/t/calling-a-jquery-function-from-rjs-onclick/173368>\
**Category:** Rails\
**Created:** [August 7, 2009, 1:37pm UTC](https://www.ruby-forum.com/t/calling-a-jquery-function-from-rjs-onclick/173368 "2009-08-07T13:37:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [August 7, 2009, 1:37pm UTC](https://www.ruby-forum.com/t/calling-a-jquery-function-from-rjs-onclick/173368/1 "2009-08-07T13:37:23Z")

</div>

Hi,

I have the following jQuery function on the head of my page.

On page load, this gets called correctly.

Now there’s a link on the page that lets me add more rows and i do  
this via RJS. Here’s the code.

\<%= add\_item\_link "+" %\>

def add\_item\_link(name)  
link\_to\_function name do |page|  
page.insert\_html :before, :empty\_item, :partial=\>‘item’, :object  
=\> Item.new  
end  
end

Now this partial ‘item’ contains form elements upon which jNice needs  
to work its magic.

How can I call the jNice function after the user clicks on the  
add\_item\_link?  
Thanks.

---

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [August 10, 2009, 6:47am UTC](https://www.ruby-forum.com/t/calling-a-jquery-function-from-rjs-onclick/173368/2 "2009-08-10T06:47:57Z")

</div>

anyone?? anything?

---

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [August 10, 2009, 11:17am UTC](https://www.ruby-forum.com/t/calling-a-jquery-function-from-rjs-onclick/173368/3 "2009-08-10T11:17:47Z")

</div>

enter live(). implementing this function solved my problem.

[http://docs.jquery.com/Events/live#typefn](http://docs.jquery.com/Events/live#typefn)
