Skip to content

Instantly share code, notes, and snippets.

@seyhunak
Forked from ntreadway/page_inject.coffee
Created May 10, 2012 06:52
Show Gist options
  • Save seyhunak/2651530 to your computer and use it in GitHub Desktop.
Save seyhunak/2651530 to your computer and use it in GitHub Desktop.
Simple page inject for JQuery Mobile and Rails Partials
# Used to dynamically add a rails page view when using Jquery Mobile
# Author Nick Treadway @nicktea
@insert_page = (id, content) ->
page = $("<article id="+id+" data-role='page' data-url="+id+" data-add-back-btn='true'>" + content + "</article>")
page.appendTo('body')
$('a' + '#' + id).click ->
$.mobile.changePage(page, {transition: "slide"})
# Use (your-view.haml)
:javascript
var content = "#{escape_javascript(render :partial => 'content')}"
insert_page("your-id", content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment