1

I am using iScroll Lite base on iScroll v4.1.6 in my project and this scrolling is working perfectly fine. My structure for iscroll is given below:

<article id="contentWrapper">
    <div id="contentScroller">
           <table cellpadding="0" cellspacing="0" width="100%">
                    <TBODY>
                        <tr class="datatable_row" id="1">
                              <td width="10%">13/02/2013</td>
                     <td class="narration" width="28%">Chq paid</td>
                </tr>
                        <tr class="datatable_row" id="2">
                               <td>16/02/2013</td>
                    <td class="narration">Chq paid</td>
                 </tr>
                   </TBODY>
          </table>
    </div>
</article>  

And the Javascript code for Iscroll apply is given below:

var scrollContent;

function loaded() {
    scrollContent = new iScroll('contentWrapper');

}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', loaded, false);  

Now you can see that there are so many <tr> elements in my table which are coming dynamically having an id. Now suppose I want to scroll to <tr> which has id 7 . How can I do this?

I tried the following, but it's not working:

scrollContent.scrollToElement("#7", "1s");   

Giving error in console, which is:

Uncaught SyntaxError: Failed to execute query: '#7' is not a valid selector.

Please let me know how to scroll to a particular id using Iscroll.

vishal_g
  • 3,871
  • 4
  • 21
  • 34
  • I am not quite sure that you can use number as an ID. You could have try ID as "tr_1", "tr_2", "tr_3", "tr_4" ... And your iScroll instance is "scrollContent" not "myScroll", and the time you have to pass in integer format if I am not mistaken. I used this "scrollToElement" a lot but all the time I use integer for timestamp and never use number for DOM id. But I never end up in any issue so far – Faizul Hasan Jan 17 '14 at 04:18
  • @FaizulHasan I also tried with ID as you said like "tr_1", "tr_2" but no use of it. Scroll is not happening to that perticular ID. If any sample you have , can you share with me. – vishal_g Jan 17 '14 at 04:53
  • check by changing the default option "checkDOMChanges" to true – Faizul Hasan Jan 17 '14 at 08:41
  • I think you might have to refer http://cubiq.org/iscroll-4 for further information. You use lite version but I use normal version. Please refer "KNOWN ISSUES AND FUTURE DEVELOPMENT" under "ISCROLL LITE EDITION". I think that could be reason. – Faizul Hasan Jan 17 '14 at 08:46
  • I am not quite sure what messed up here. But I have to make sure your iScroll is working with your current implementation( I am not asking about the scrollToElement). Please make sure whether it is working or not. Because I found incompatible DOM structure for iScroll. Please refer my answer here http://stackoverflow.com/questions/16980231/how-to-use-iscroll-javascript-in-phone-gap/17114527#17114527 – Faizul Hasan Jan 20 '14 at 08:44

0 Answers0