Last Updated: February 25, 2016
·
1.438K
· nicktea

Simple page inject for JQuery Mobile and Rails Partials

@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);