Search code examples
ruby-on-railsrubygemscolorbox

Colorbox-rails inline content


After I install colorbox-rails

**followed the directions on this page: http://rubydoc.info/gems/colorbox-rails/0.0.9/file/README.rdoc **here is what the readme says to use for the link_to

<%= link_to "My superb link", "#", :data => { :colorbox => true } %>

I added this to my link_to

:data => { :colorbox => true }

it works does a popup, but I can't get it to link to the content I want. It will display either the page you are on in the colorbox or an error message "This content failed to load."

I am trying to get a contact form in the colorbox.

I am running Rails 3.2.8


Solution

  • Do

    <%= link_to "My superb link",show_contact_path(@contact.id), :data => { :colorbox => true } %>
    

    Edit

    You can also do

    // Called directly, without assignment to an element:
    $(".myElement").colorbox({href:"thankyou.html"});
    
    // Called directly with HTML
    $(".myElement").colorbox({html:"<h1>Welcome</h1>"});
    

    http://www.jacklmoore.com/colorbox

    Just make sure you create the selector for the element class="myElement"

    Also (credit to One Two Three)

    If the link is external (ie., going to site other than your own application's), you'd need to specify the iframe attribute as follows :colorbox_iframe => true