User an RJS template for the javascript response

This commit is contained in:
Tom Hughes 2011-05-09 00:30:06 +01:00
parent ae844f3260
commit c7bb260b4c
3 changed files with 8 additions and 9 deletions

View file

@ -42,7 +42,7 @@ class MapBugsController < ApplicationController
@bugs = MapBug.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions) @bugs = MapBug.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions)
respond_to do |format| respond_to do |format|
format.html {render :template => 'map_bugs/get_bugs.js', :content_type => "text/javascript"} format.html {render :template => 'map_bugs/get_bugs.rjs', :content_type => "text/javascript"}
format.rss {render :template => 'map_bugs/get_bugs.rss'} format.rss {render :template => 'map_bugs/get_bugs.rss'}
format.js format.js
format.xml {render :template => 'map_bugs/get_bugs.xml'} format.xml {render :template => 'map_bugs/get_bugs.xml'}
@ -187,7 +187,7 @@ class MapBugsController < ApplicationController
:conditions => conditions) :conditions => conditions)
@bugs = bugs2.uniq @bugs = bugs2.uniq
respond_to do |format| respond_to do |format|
format.html {render :template => 'map_bugs/get_bugs.js', :content_type => "text/javascript"} format.html {render :template => 'map_bugs/get_bugs.rjs', :content_type => "text/javascript"}
format.rss {render :template => 'map_bugs/get_bugs.rss'} format.rss {render :template => 'map_bugs/get_bugs.rss'}
format.js format.js
format.xml {render :template => 'map_bugs/get_bugs.xml'} format.xml {render :template => 'map_bugs/get_bugs.xml'}

View file

@ -1,7 +0,0 @@
<% if @bugs.empty? %>
<% else %>
<% @bugs.each do |bug| %>
putAJAXMarker(<%= bug.id.to_s %> , <%= bug.lon.to_s %> , <%= bug.lat.to_s %> , '<%= escape_javascript(bug.flatten_comment("<hr />")) %>', <%= (bug.status=="open"?"0":"1") %> );
<% end %>
<% end %>

View file

@ -0,0 +1,6 @@
@bugs.each do |bug|
page.call "putAJAXMarker",
bug.id, bug.lon, bug.lat,
bug.flatten_comment("<hr />"),
bug.status == "open" ? 0 : 1
end