Solved

jquery if else statement for ipad and smooth-div-scroll plugin

Posted on 2013-01-16
4
760 Views
Last Modified: 2013-01-16
Hello,
 I am using the jquery smooth-div-scroll plugin and it works on ipad with one set of plugin initialization options and works on a windows tablet with a different set of initialization options. (the windows tablet setting also works for everything else)

So, I am trying to use a jquery if/else to basically say,

   If user is ipad then do this-

               use these plugin options:                
        touchScrolling: true,
        manualContinuousScrolling: false

               else (otherwise use these options)-
                              hotSpotScrolling: true,
                              manualContinuousScrolling: false

Here's what I have so far but don't know how to correctly inject the else statement into this. Can someone please help with this part?

<script type="text/javascript">

                       $(document).ready(function () {

        var browser = navigator.userAgent;
        if (browser.match(/iPad/i)) {
     }
                      $("div#ScrollContainer").smoothDivScroll({

                            touchScrolling: true,
                           manualContinuousScrolling: false
    });
    });
   </script>
0
Comment
Question by:kmkmediagroup
  • 3
4 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 500 total points
ID: 38784071
<script type="text/javascript">
$(document).ready(function () {

        var browser = navigator.userAgent;
        if (browser.match(/iPad/i)) {

                      $("div#ScrollContainer").smoothDivScroll({

                            touchScrolling: true,
                           manualContinuousScrolling: false
    });

     } else {
                      $("div#ScrollContainer").smoothDivScroll({
hotSpotScrolling: true,
                              manualContinuousScrolling: false
    });
}

    }); 
   </script>

Open in new window


Seems like messy one but when you tidy up, it should work.
0
 

Author Comment

by:kmkmediagroup
ID: 38784152
Thank you much but its not working. That's basically what I was trying to do too. Program says there is a syntax error on line 4. (but its probably somewhere else as line 4 seems fine to me)

But what I do know is that the result it is applying the first set of options to ALL - so seems to be ignoring the "else" part.  Any ideas?
0
 

Author Comment

by:kmkmediagroup
ID: 38784297
Ooops, I take that back. It worked. Not sure why it didn't the first time - I think I just may have omitted the closing script tag or something, but is working now!
Thank you!!
0
 

Author Closing Comment

by:kmkmediagroup
ID: 38784300
Thanks for the super quick response!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Editing Powershell script to resolve DNS from HashTable ? 7 50
home folder path for users 4 57
Animated .jpg? 13 57
How can I save all open docs into a given folder 12 83
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now