ruby - set jquery mobile attributes in rails paginate -


i have mobile page app uses jquery mobile "collapsible" data-role hide microposts (hartl's tutorial) until user clicks them expand.

i use modified paginate render paginate links. https://gist.github.com/jugyo/3135120

<div data-role="collapsible">   <h3>show microposts (<%= @user.microposts.count %>)</h3>   <ul data-role="listview">     <%= render @microposts %>   </ul>   <%= will_paginate @microposts,      renderer: willpaginate::actionview::jquerymobilepaginatelinkrenderer,     previous_label: 'prev',     next_label: 'next'   %> </div> 

my question is: how add event paginate click? want have list collapsed (the default), data-role="collapsible" when page first loaded, when click next (or later, prev) want collapsible container add data-collapsed="false" attribute list open. (it doesn't make sense click next , go collapsed list again)

do put in rb has paginate code? if so, how refer page elements? or put jquery somewhere...?

any assistance appreciated.

you can add class or id pagination. i'll add id :

<%= will_paginate @microposts,    renderer: willpaginate::actionview::jquerymobilepaginatelinkrenderer,   id: 'my_pagination',   previous_label: 'prev',   next_label: 'next' %> 

then give main div kind of identifier :

<div data-role="collapsible" id="my_list"> 

now can activate manually jquery :

$("#my_pagination").click(function() {      $("#my_list").data("collapsed", $("#my_list").data('collapsed') == 'false' ? 'true' : 'false')   }); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -