Session in client side

11 views
Skip to first unread message

Avi

unread,
Sep 12, 2012, 5:15:25 AM9/12/12
to rubyonra...@googlegroups.com
Hello,

I have a page. In that I am showing dropdown list. According to the values I am viewing the tables.
When I am selecting values from the dropdown, it renders a table & views it.
Everything is happening on client side. When I refresh the page, it goes to the fist value in the dropdown (rather I should be in the last selected dropdown value).
How can I manage this in client side session ?

Thanks

Colin Law

unread,
Sep 12, 2012, 5:25:54 AM9/12/12
to rubyonra...@googlegroups.com
I don't understand what you mean by client side session. If you mean
how to use the session variable in rails then have a look at the Rails
Guide on Active Controller, it has a section of the use of the session
variable.

While you are at it work through all the other guides, they will
answer many of your questions.

Also work right through a tutorial such as railstutorial.org which
will introduce you to the basics of Rails.

Colin

>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-ta...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rubyonrails-talk/-/A3UN_4p1wN8J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Avi

unread,
Sep 12, 2012, 6:03:16 AM9/12/12
to rubyonra...@googlegroups.com, cla...@googlemail.com
Here is my code :-

<script type="text/javascript">
    $(document).ready(function () {
          $('#table_user_registration').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers"
        });
        $('#table_download_file').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers"
        });
        $('#table_user_activation').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers"
        });
        $("#user_registration").show(); // Default I am setting to this on coming to this page. How can I change this ?
    });
   
     var chng = "user_registration";
     function audit_options(selected_audit){
        $("#"+ chng ).hide();
        $("#" + selected_audit ).show();
        chng = selected_audit;
     }
   
</script>

<select id="audit_options" onchange="audit_options(this.value);" >
    <option value="user_registration">User Registration</option>
    <option value="download_file">File Download</option>
    <option value="user_activation">User Activation</option>
</select>

<div id="user_registration" style="display: none" >
    I have here my Table 1
</div>
                       
<div id="download_file" style="display: none" >
    I have here my Table 2
</div>
                       
<div id="user_activation" style="display: none">
    I have here my Table 3
</div >

So, if Iam in 2nd value in the dropdown. & I do a refresh page. It comes to the first.

Hassan Schroeder

unread,
Sep 12, 2012, 10:36:49 AM9/12/12
to rubyonra...@googlegroups.com
On Wed, Sep 12, 2012 at 3:03 AM, Avi <aavinas...@gmail.com> wrote:

> $("#user_registration").show();
> // Default I am setting to this on coming to this page. How can I change this ?

1) set the value on the server on select and get it back on page reload
2) save it to a cookie
3) save it to HTML5 Local Storage

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Reply all
Reply to author
Forward
0 new messages