Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Created July 19, 2011 12:12
Show Gist options
  • Save bjhaid/1092116 to your computer and use it in GitHub Desktop.
Save bjhaid/1092116 to your computer and use it in GitHub Desktop.
application.js
1 // Place your application-specific JavaScript functions and classes here
2 // This file is automatically included by javascript_include_tag :defaults
3 $(function() {
4 setTimeout(updateCalls, 500);
5 });
6
7 function updateCalls () {
8 if ('data-user' == 'data-exten') {
9 var after = $('.call:last').attr('data-time');
10 $.getScript("/switchvoxes.js?" + "&after" + after);
11 setTimeout(updateComments, 500);
12 }
13 }
index.html.erb
1 <h1>Listing switchvoxes</h1>
2 <table>
3 <tr>
4 <th>Cid number</th>
5 <th>Exten number</th>
6 <th></th>
7 <% if user_signed_in? %>
8 <th><%= current_user.username %></th>
9 <% end %>
10 <th></th>
11 <th></th>
12 </tr>
13 <div id=switchvoxes data-user="4560">
14 <% Switchvox.all.each do |switchvox| %>
15 <tr>
16 <div id = "call" data-id="<%=switchvox.id%>" data-time="<%=switchvox.created_at.to_i%>" data-exten="<%=switchvox.exten _number%>" >
17 <td><%= switchvox.cid_number %></td>
18 <td><%= switchvox.exten_number %></td>
19 <td><%= link_to 'Show', switchvox %></td>
20 <td><%= link_to 'Edit', edit_switchvox_path(switchvox) %></td>
21 <td><%= link_to 'Destroy', switchvox, :confirm => 'Are you sure?', :method => :delete %></td>
22 </div>
23 </tr>
24 </div>
25 <% end %>
index.js.erb
alert('works')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment