简体   繁体   中英

Hobo: is that possible to add cookies to table-plus?

I am having some trouble with the sorting provided by table-plus feature in hobo. Let's say I have some javascript functions to display different tables:

function showTable1() {
    ...
}


function showTable2() {
    ...
}


function showTable3() {
    ...
}

Event.observer(windows, 'load', showTable1);

and I am using to display the tables. As we can see, Table 1 will be shown by default and every time when I try to sort, let say, Table 2 after displaying it, the page will refresh and then it will automatically switch back to show Table 1.

I am planning to replace the default behavior by a handler:

function showHandler() {
    if (case1) showTable1();
    else if (case2) showTable2();
    else showTable3();
}

Is this possible to implement it by adding cookies to the table-plus behavior? is there any better way to do it?

It's generally easiest if you do everything all server-side or all client-side in a Rails or Hobo app.

So either switch to hobo_data_tables and sort on the client side or do the display toggling server side. To do the latter, you can add forms like this:

<form action="">
  <input type="hidden" name="search" value="&params[:search]"/>
  <input type="hidden" name="sort" value="&params[:sort]"/>
  <input type="hidden" name="page" value="&params[:page]"/>
  <input type="hidden" name="table" value="2"/>
  <submit label="Show page 2"/>
</form>

Then put if statements around each table:

<if test="&params[:table].to_i==2">
   <h2> table 2 </h2>      
   <table-plus .../>
</if>

I also recommend posting to hobo-users -- there's a much more active community there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM