Created
August 18, 2014 19:42
-
-
Save oferreiro/0445bb6486f7609999a7 to your computer and use it in GitHub Desktop.
Render a javacript on rails with haml.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Place all the behaviors and hooks related to the matching controller here. | |
# All this logic will automatically be available in application.js. | |
# You can use CoffeeScript in this file: http://coffeescript.org/ | |
jQuery -> | |
setInterval(-> | |
console.log "Getting table..." | |
$.ajax( | |
url: "/" | |
dataType: "script" | |
type: "GET" | |
).done (data) -> | |
console.log data | |
,10000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%table#reload-table | |
%tr | |
%th Alias | |
%th Hostname | |
%th | |
%th | |
%th | |
- @registers.each do |register| | |
%tr | |
%td= register.alias | |
%td= register.hostname | |
%td= link_to 'Show', register | |
%td= link_to 'Edit', edit_register_path(register) | |
%td= link_to 'Destroy', register, :method => :delete, :data => { :confirm => 'Are you sure?' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%h1 Listing registers | |
= link_to "table via js", registers_path, remote: true | |
= render "table" | |
%br | |
= link_to 'New Register', new_register_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:plain | |
(function() { | |
jQuery(function() { | |
console.log("reloading table"); | |
$("#reload-table").html("#{escape_javascript render 'table'}"); | |
}); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment