]> git.openstreetmap.org Git - rails.git/commitdiff
User an RJS template for the javascript response
authorTom Hughes <tom@compton.nu>
Sun, 8 May 2011 23:30:06 +0000 (00:30 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 17 May 2011 23:36:01 +0000 (00:36 +0100)
app/controllers/map_bugs_controller.rb
app/views/map_bugs/get_bugs.js.erb [deleted file]
app/views/map_bugs/get_bugs.rjs [new file with mode: 0644]

index a3984347bd3cc8cd6775a8714cf3832bb66afdb8..bd91c1281c4ff8daf586a06fcd5861f995963a46 100644 (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)
 
     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.js
       format.xml {render :template => 'map_bugs/get_bugs.xml'}
@@ -187,7 +187,7 @@ class MapBugsController < ApplicationController
                         :conditions => conditions)
     @bugs = bugs2.uniq
     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.js
       format.xml {render :template => 'map_bugs/get_bugs.xml'}
diff --git a/app/views/map_bugs/get_bugs.js.erb b/app/views/map_bugs/get_bugs.js.erb
deleted file mode 100644 (file)
index 5bc9aaf..0000000
+++ /dev/null
@@ -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 %>
\ No newline at end of file
diff --git a/app/views/map_bugs/get_bugs.rjs b/app/views/map_bugs/get_bugs.rjs
new file mode 100644 (file)
index 0000000..7268ded
--- /dev/null
@@ -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