0

I use a grid to simulate some kind of splitview where I want to use the left side together with a listview to show some navigation buttons and the right side to show some content.

now the listview is really long and I want to have it scrollable. so the listview pane should be scrollable while the content pane stays in full screen height (or later gets its own scrollable content pane). how is this possible with jQM? thnx!

Gajotres
  • 57,309
  • 16
  • 102
  • 130
headkit
  • 3,307
  • 4
  • 53
  • 99

1 Answers1

2

Solution

What you want can't be done that easily. No matter on what platform are you working it is almost impossible to create 2 scrollable panes and that each of them works separately, specially on mobile devices. But as always there's a workaround.

Working example: http://example.gajotres.net/iscrollview/

I can't create you a jsFiddle because iscrollview don't work in that environment. If you already dont know, iscrollview is jQuery mobile plugin create as a wrapper around iscroll. Iscroll is plugin create to give a scrollable content to mobile browsers.

This implementation uses fixed floating right panel. While rest of the page is scrollable this panel will give you an illusion like it is fixed on a right side of the page.

Tested on

  1. Windows Firefox
  2. Windows Chrome
  3. Android Chrome
  4. Stack Samsung Galaxy S3 Android browser

HTML :

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/>

            <link rel="stylesheet" href="http://www.fajrunt.org/css/jquery.mobile-1.3.1.min.css" />
            <link rel="stylesheet" href="http://www.fajrunt.org/css/jquery.mobile.iscrollview.css" />
            <link rel="stylesheet" href="http://www.fajrunt.org/css/jquery.mobile.iscrollview-pull.css" />   
            <style>
                #iscroll-listview {
                    margin: 0 !important;
                }

                .right-pane {
                    position: fixed;
                    width: 50%;
                    height: 100%;
                    background: red;
                    top:0;
                    color: white;
                    margin-top: 40px;
                }
            </style>
            <script src="http://www.fajrunt.org/js/jquery-1.9.1.min.js"></script>
            <script src="http://www.fajrunt.org/js/jquery.mobile-1.3.1.js"></script>    
            <script src="http://www.fajrunt.org/js/iscroll.js"></script>
            <script src="http://www.fajrunt.org/js/jquery.mobile.iscrollview.js"></script> 
        </head>

        <body>
            <div data-role="page" class="index-page">

                <div data-role="header" data-position="fixed" data-tap-toggle="false" data-transition="none" data-id="header">
                    <h1>INDEX PAGE</h1>
                </div>

                <div data-role="content">
                    <div class="ui-grid-a">
                        <div class="ui-block-a" >
                            <div class="example-wrapper" data-iscroll>
                                <p>some content that will be scrolled</p>
                                <p>Some more content that will be scrolled</p>
                                <ul data-role="listview" id="iscroll-listview">
                                    <li>Item 1</li>
                                    <li>Item 2</li>
                                </ul>
                                <p>Even more content. It will scroll whatever is in the data-iscroll div.</p>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>
                                <h1>Hello Cirrus.</h1>   
                            </div>          
                        </div>
                        <div class="ui-block-b">
                            <div class="right-pane">
                                This is a right pane.<br>
                                This is a right pane.<br>
                                This is a right pane.<br>
                                This is a right pane.<br>
                                This is a right pane.<br>
                                This is a right pane.<br>
                                This is a right pane.<br>                               
                            </div>                          
                        </div>
                    </div><!-- /grid-a -->        
                </div>

                <div data-role="footer" data-position="fixed" data-tap-toggle="false" data-transition="none" data-id="footer">
                    <h1>My Footer</h1>
                </div>

            </div>
        </body>
    </html>

Final notes

If you want to find out more about iScroll + iScrollView, how they work with working examples then take a look at this article.

Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • great answer, thanx! yes, I stumbled over iscrollview, too. but is the use of iscrollview neccessary? isn't it enough to set the right-pane to fixed position? by the way: on jsbin its working: http://jsbin.com/oqarih/2/ – headkit May 16 '13 at 11:42
  • From you tags I have understood you need this for iPad (or other mobile devices). If this is true then you need iscrollview for a large listview. iscrollview is not needed on desktop browser because they don't suffer from touch problem like touch devices. One last thing if you are only building an app for an iOS devices then there's a solution that don't requires iscrollview but it unfortunately works only on iOS devices. – Gajotres May 16 '13 at 11:47
  • I need something for mobile and desktop and I like this solution. but some issues have to be solved: there should not be a scrollbar for the listview OR the scrollbar needs to be displayed directly right to the scroll-list inside the left-pane and not right to the right-pane. is this possible? – headkit May 16 '13 at 12:06
  • Basically no, this is a complex problem. On desktop browsers you can create a solution that will have a customs scrollbar only in left pane. But at the same time this is impossible on mobile devices. On mobile devices you cant scroll large listview without iscrollview and that same iscrollview will trigger classic browser scrollbar on a right side of a browser. – Gajotres May 16 '13 at 12:16
  • damn. the simplest feature requests produce the biggest problems... what about using a slide-panel as sidebar, which is initially opened? instead of the grid-solution. – headkit May 16 '13 at 12:18
  • To be honest I was also thinking about same idea but currently don't have time to test it. I will try it during this day. – Gajotres May 16 '13 at 12:27
  • Thats great, thnx! I also played around with this and it seems not to be the path to go, because either it is overlaying or pushing the content-pane away. in all threee states it is overlaying/masking the content. :-( seems that jQM is not ready to be used for scripting serious web apps... – headkit May 16 '13 at 13:16
  • Unfortunately We will need to wait at lease version 1.4 to see this possibly work. What have you choose then? Are you going to abandon this route? – Gajotres May 16 '13 at 13:18
  • I am thinking about going back to sencha touch and/or ExtJS. But here you need to purchase a license. another last route with jQM could be worth a try: https://github.com/asyraf9/jquerymobile-splitview – headkit May 16 '13 at 13:35
  • Be careful with this plugin, it is unstable with latest jQM versions. I think developer made a custom jQM framework to work with this plugin. Just read everything carefully. – Gajotres May 16 '13 at 13:42
  • One last thing, good luck. I like jQM but it is a pain in the *** :) – Gajotres May 16 '13 at 14:02
  • yea, read about this, too. can't use it. so let's see if this one is 1.3-ready: http://simplesplitview.sourceforge.net/ – headkit May 16 '13 at 14:15
  • back on the road. it work relatively well with two floating divs as pane-containers and some jquery-magic (set height()) and CSS-powder (overflow-y:scroll)... – headkit May 16 '13 at 20:32