Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [rails] Clean incrementer across Ajax calls?

Thread Tools

[rails] Clean incrementer across Ajax calls?

Nate Murray
Posts: n/a
Hey all, I want to have an ajax call that increments a number each time
it is
called. Basically I have want to render a partial that contains a call
append that same partial again at the end of the div. Perhaps it will
if I give the example code.

So in my view.rhtml i have:
=== view.rhtml ===
<div id="where_clause_div">
<%= link_to_remote 'Add',
{ :update => 'where_clause_div',
:url => { :action => :make_where_clause },
osition => :after} %><br />

And in my controller I have:
=== controller.rb ===
def make_where_clause
@where_clause_id = 1 unless @where_clause_id; # This is always 1
render artial => 'where_clause',
:locals => { :clause_id => @where_clause_id }
@where_clause_id += 1

And the partial is:
=== _where_clause.rhtml ===
<div class="where_clause" id="where_clause_<%= @where_clause_id %>">
The ID is: <%= @where_clause_id %>
<%= link_to_remote 'Add',
{ :update => 'where_clause_div',
:url => { :action => :make_where_clause },
osition => :after} %>

My end goal is to get the "where_clause" div id in the partial to be
incremented on each ajax call. The only requirement is that I can't
the partial just increment its own variable because the 'add' link will

remain on each of the divs.

Is there a clean way (short of a session variable) to do what I am
looking to do?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
persist js-block-resident state across ajax downloads? Thomas 'PointedEars' Lahn Javascript 5 12-05-2009 04:25 PM
Visual C++'s :"clean solution" doesn't clean the solution? C++ 8 05-31-2008 04:57 PM
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM
How do I clean a virus within an inbox or just clean only that infectedattachment or LOCATE AND delete just that attachment ? Vinayak Firefox 1 08-14-2006 06:19 PM
Clean up my Hard drive before selling it. Clean Registry? what else? baaab Computer Support 5 05-10-2005 08:30 AM