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 6722569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:27:46+00:00 2026-05-26T09:27:46+00:00

I have a function SomeFunction(event) – I want to bind a ‘tap’ event to

  • 0

I have a function SomeFunction(event) –
I want to bind a ‘tap’ event to a (‘#selectorid’) element, and I want to know what is the right syntax:

should I use:

 $('#selectorid').unbind().bind('tap',SomeFunction);   

or:

  $('#selectorid').unbind().bind('tap',function(event){
    SomeFunction(event);});});

or:

 $('#selectorid').unbind().bind('tap',function(){
       SomeFunction(event);}); 

or

$('#selectorid').unbind().bind('tap',SomeFunction(event));   

I’m getting completely mixed up about this and would be glad for some clarification..

I’m using the lateset rc2 jquery mobile

  • 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-05-26T09:27:46+00:00Added an answer on May 26, 2026 at 9:27 am

    #1 should get the job done, but requires that you have “SomeFunction” defined globally:

    $( "#selectorid" ).unbind().bind( "tap", SomeFunction );
    

    What will happen is when the event is fired, it will call same “SomeFunction” and pass the event as it’s first parameter, So all you have to do is define SomeFunction, like so:

    SomeFunction( p_event )
    {
      // Do cool evil stuff with the event parameter like cancel the tap event >:)
      p_event.preventDefault();
      // That's it. :)
    }
    

    #2 will also work, but again, will require “Somefunction” to be defined globally.

    $( "#selectorid" ).unbind().bind( "tap", function(p_event)
    {
        SomeFunction( p_event );
    });
    

    What will happen in the case of #2, is that the anonymous function will call the “SomeFunction” and pass along the event, just like in the first example, but with an extra step. Which is why I prefer the first method. 🙂

    #3 and #4 have errors and are just bad version of the previous two.

    Also, what I mean by globally defined, is that the “SomeFunction” is available everywhere on the page, and not just defined in an object, plugin, or closure. Because if it were, then calling it in your event handler may produce undefined errors. If your wondering, I like to use double quotes with my strings and pre-pend my parameter variables with ‘p_’, so I can use the same variable name in the function, and easily distinguish between the two. It my personal naming convention. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have function getCartItems in cart.js and I want to call that function in
Suppose I have a class like this: function myClass(q) { this.someFunction = function(e) {
suppose we have following function: void someFunction(int * araye){ for (int i=0;i<5;i++) cout <<araye[i]<<'
I have a <div> element that has a click event attached to it using
What's the event to bind for when a select form is selected? I have
For instance I have a function: function somefunction () { $('someselector').fadeOut('slow', function() { $(this).remove;
I have some function to find a value: struct FindPredicate { FindPredicate(const SomeType& t)
When I have some function of type like f :: (Ord a) => a
So I have some function that receives N random 2D points. Is there any
In JavaScript, if I have some function I can use the arguments object to

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.