Popup window

How can I insert (:popup => true) into code below?

<%= link_to “Source_#{i}”, link.url , :style => “color:#0096FF;font-
family:‘LucidaGrande’,‘Lucida Grande’,‘Lucida Sans Unicode’,sans-
serif; font-size: 11px; text-decoration: none; margin-right: 10px;” if
link.show? %>

Just add :target => “_new”

**<%= link_to “Source_#{i}”, link.url, :target => “_new”, :style =>
“color:#0096FF;font-family:‘LucidaGrande’,‘Lucida Grande’,‘Lucida Sans
Unicode’,sans-serif; font-size: 11px; text-decoration: none;
margin-right:
10px;” if link.show? %>

If your page is in a Strict doctype, then you can’t use the target
attribute. (In a Transitional doctype, target="_blank" will give you
an endless succession of new windows, one for each link;
target=“anything” will give you one new window over and over, with the
JavaScript name “anything”, and it will keep re-using it.)

Instead, you have to use JavaScript to open the window. You can do
this inline, with

:onclick => ‘window.open(this.href, “someName”);’

or you can use another attribute as a hook for unobtrusive JavaScript.
I prefer the latter, and use

:rel => ‘new_window’

and then

$$('a[rel*=“new_window”]).invoke(‘observe’,‘click’,function(evt){
evt.stop();
return window.open(this.href,‘someName’);
});

Put that in a script block at the bottom of the page, or inside a
listener on the dom:loaded event, so it’s set up when the page loads.

Walter

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs