· 1 min read

Screencast: Unobtrusive Javascript in Rails 3

Download:

Download (27.4 MB, 13:18) Alternativer Download für iPod & Apple TV (17.7 MB, 13:18)

Resourcen:

Quellcode:

[html]

UJS Example

Click Here

<%= javascript\_include\_tag :defaults %> <%= javascript\_include\_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "jquery.rails.js" %> <%= csrf\_meta\_tag %> <% form\_tag products\_path, :method => :get, :remote => true do %>

<%= text\_field\_tag :search, params\[:search\] %> <%= submit\_tag "Search", :name => nil %>

<% end %>
<%= render @products %>
\[/html\]

[html] // products/index.js.erb $(“products”).update(”<%= escape_javascript(render(@products)) %>”); // or $(“#products”).html(”<%= escape_javascript(render(@products)) %>”); [/html]

Back to Blog