Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7731611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:31:24+00:00 2026-06-01T06:31:24+00:00

I have the following template in Backbone, all gets rendered perfectly. <a href=#list data-role=button

  • 0

I have the following template in Backbone, all gets rendered perfectly.

    <a href="#list" data-role="button" id="button" class="all-unselected"></a>
    <a href="#" data-role="button" id="button" class="suggested-unselected"></a>
    <a href="#" data-role="button" id="button" class="friends-unselected"></a>
    <a href="#" data-role="button" id="button" class="private-unselected"></a>
    <a href="#" data-role="button" id="button" class="buzz-unselected"></a>
    <script type="text/javascript">
        var buttons = $("a#button");

        for(var i=0; i<buttons.length; i++){
            $(buttons[i]).bind('touchstart', select, false);
            $(buttons[i]).bind('touchend', unselect, false);
        }

        function select(){
            alert('test');
        }
        function unselect(){
            alert('unselect');
        }
    </script>

The touchstart doesn’t get triggered however if I write the following:

    <a href="#" data-role="button" id="button1" class="suggested-unselected"></a>
    <script type="text/javascript">
            document.getElementById('button1').addEventListener('touchstart', select, false);

        function select(){
            alert('test');
        }
        function unselect(){
            alert('unselect');
        }
    </script> 

it works. As if jQuery can’t bind the event. What might be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:31:25+00:00Added an answer on June 1, 2026 at 6:31 am

    There are a couple of issues in your code.

    First of all:

    var buttons = $("a#button");
    

    This selects an anchor element with the id button. As ids should be unique, this should only return one element. Yet, you are trying to loop through the returned value. That should not be working the way you are trying to do it.

    Second:

    If you have a set of jQuery object that you have selected you usually use .each() to iterate over them. Yet, if you are trying to bind an event handler to a set of objects you don’t even have to do this in a loop as jQuery is able to bind an event to a selection.

    Third:

    .bind()-ing works different, you are mixing .bind() – syntax with addEventListener syntax.

    So, to translate your working non-jQuery-example (it’s not bad not to use jQuery btw) into jQuery this would look like:

    $('#button1').bind('touchstart', select);
    $('#button1').bind('touchend', unselect);
    
    function select(){
    alert('test');
    }
    
    function unselect(){
    alert('unselect');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML code: <ul id='item-list'></ul> <button id='add-item'>Add Item</button> <script type='text/template' id='item-template'>
I have the following template method declared in my interface: class IObjectFactory { public:
We have following class definition template<typename T> class Klass {...} and we also have
I have he following interface: template <class T> class AbstractTask { public: virtual void
I have the following class: template <typename T> class Fixed2DContainer { T* ptr; public:
I have following class: template <size_t size> class Araye{ public: Araye(int input[]){ for (int
I have the following template class: template<class T> class C { typedef C_traits<T> traits;
Say I have the following template function: template <class T> void apply(const vector<complex<T> >&
I have the following class template: template<class T, unsigned N> class MyClass; where T
I have the following views: window.DmnView = Backbone.View.extend({ template: _.template($(#tmpl_dmnListItem).html()), events: { click .getWhois:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.