Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11401 (new defect)

Opened 4 months ago

Last modified 4 months ago

[PATCH] insert_html uses Insertion namespace, deprecated in Prototype 1.6

Reported by: dancroak Assigned to: sam
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: prototype, rjs
Cc:

Description

In action_view/helpers/prototype_helper.rb, insert_html uses the deprecated Insertion namespace from Prototype.

I think the new method needs to be something like:

def insert_html(position, id, *options_for_render)

content = escape_javascript render(*options_for_render) record "Element.insert('#{id}', { #{position.to_s}: '#{content}' });"

end

I couldn't get escape_javascript (from javascript_helper) to fire correctly, so I replaced it with:

def insert_html(position, id, *options_for_render)

content = render(*options_for_render).gsub('\\','\0\0').gsub('</','<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" } record "Element.insert('#{id}', { #{position.to_s}: '#{content}' });"

end

This does insert the html, but not in the correct position, and throws an RJS error. I may keep toying with this, but I think someone else will have to finish it.

Also, the Insertion namespace is used on line 1011 of trunk, in the options_for_ajax method.

Attachments

change_insertion_new_for_element_insert.diff (8.6 kB) - added by miloops on 03/31/08 01:59:53.
Patch with tests and docs updated.

Change History

03/31/08 01:59:53 changed by miloops

  • attachment change_insertion_new_for_element_insert.diff added.

Patch with tests and docs updated.

03/31/08 02:04:34 changed by miloops

  • summary changed from insert_html uses Insertion namespace, deprecated in Prototype 1.6 to [PATCH] insert_html uses Insertion namespace, deprecated in Prototype 1.6.

I attach patch to fix this, updated tests and docs.

options_for_ajax also changed to be prototype 1.6 compliant: "..., such as Insertion.Bottom. As of Prototype 1.6.0, this notation is deprecated. Simply pass either 'top', 'bottom', 'before' or 'after' as a string instead."

03/31/08 12:48:54 changed by cavalle

+1 Tests pass