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

Ticket #5437 (new defect)

Opened 2 years ago

Last modified 2 years ago

Minor api inconsistency between page.select('some_class').first.replace and page['some_id'].replace

Reported by: jacek.becela@gmail.com Assigned to: David
Priority: low Milestone: 2.x
Component: ActionPack Version: 1.1.1
Severity: trivial Keywords:
Cc:

Description

This code doesn't work as expected:

wants.js do 
        render :update do |page|
          page.select('#link-1 .details').first.replace :partial => 'edit'
        end
      end

When I pass options for render directly to the replace function, the hash is converted to string and passed to the browser resulting in alert saying that html.stripScripts() is not a function.

However, when i pre-render partial using render_to_string, it works as expected:

wants.js do 
        partial = render_to_string :partial => 'edit'
        render :update do |page|
          page.select('#link-1 .details').first.replace partial
        end
      end

Also when I explicitly select DOM element by id, everything works:

page['link-1'].replace :partial => 'edit'

Change History

06/27/06 20:51:23 changed by jacek.becela@gmail.com

Uhh, it works when you put add one word between replace and :partial. The word is render. So it just looks like an api inconsistency between pagesome_id?.replace and page.select('some_class').first.replace

wants.js do 
        render :update do |page|
          page.select('#link-1 .details').first.replace :partial => 'edit'
        end
      end

06/27/06 20:53:56 changed by jacek.becela@gmail.com

  • severity changed from normal to trivial.
  • summary changed from page.select('#someid .someclass').frist.replace works with strings but not with hash for render to Minor api inconsistency between page.select('some_class').first.replace and page['some_id'].replace.

Changing summary to more descriptive...