Skip to content

Instantly share code, notes, and snippets.

@beneggett
Created November 8, 2013 22:49
Show Gist options
  • Save beneggett/7378953 to your computer and use it in GitHub Desktop.
Save beneggett/7378953 to your computer and use it in GitHub Desktop.

Replace your old links with a Rails AJAX helper link (remote: true)

<%= link_to "Show More >", project_path(project), remote: true %>

Format your controller to respond to javascript

format.js

Create a new view for the javascript action show.js.erb / show.js.coffee

Write the appropriate javascript to do what you want

(app/views/projects/show.js.coffee)

$(".modal-target").html("<%= escape_javascript (render 'projects/project_modal', project:  @project ) %>")
$("#project-<%[email protected] %>").modal('show')
$('.project-thumbnails img').on 'click', ->
  $(this).closest('.modal-body').find('.featured-image').attr('src', $(this).attr('data-url'))

Clean up and optimize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment