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

  • Home
  • SEARCH
  • 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 7756211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:45:51+00:00 2026-06-01T12:45:51+00:00

I am making a phonegap program and I want to use a .on(‘tap’) event

  • 0

I am making a phonegap program and I want to use a .on('tap') event instead of onClick="blah(param1,param2)" because of the 400ms delay. What I wanted to do was give a list of “tappable” items a class of “button1” and with each item give it a data-meth="dosomething3()" and then retrieve that when something is tapped. So far my example does not use tap but click instead.

       <script>
    $(document).ready(function() {
    console.log('document ready');
    $(".button1").on('click', function(e){ //this will changed to 'tap' eventually
    e.preventDefault();
    console.log("logged click");
    var tempp=$(this).data("meth");
    alert(tempp);
    tempp; // thought this would call the function as it is written in the data-meth value but it doesn't
    });

    });
    function dosomething(){
    console.log('dosomething called');

    }
function dosomething(var1,var2){
alert('hello:' +var1+' just showing var2'+var2);
}

    </script>

My simple html is 

    <ul>
    <li style="text-align:center" class="button1" data-meth="dosomething()" >One</li>
    <li style="text-align:center"  class="button1" data-meth="dosomething2(var1,var2)">Two</li>
    <li style="text-align:center" class="button1" data-meth="dosomething3()">Three</li>
    </ul>

How can i grab and call the function based or what is stored in the data-meth value?

  • 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-01T12:45:53+00:00Added an answer on June 1, 2026 at 12:45 pm

    Off the top of my head:

    $(".button1").click(function() {
        var functionName = $(this).attr("data-meth").split("(")[0];
        var functionParams = $(this).attr("data-meth").split(")")[0].split[","];
        window[functionName](functionParams);
    });​
    

    functionParams would be an array containing your values. That may or may not be what you need. You could also use the ever-evil eval like so:

    $(".button1").click(function() {
        eval($(this).attr("data-meth"));
    });​
    

    In which case you could pass in your parameters and treat them as usual.

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

Sidebar

Related Questions

I have an application that is making use of the PhoneGap (version 1.4.1). It
i'm making a project for school and I want to use the phone gap
I'm making a web-app with PhoneGap. Here's my current hurdle: On page one, the
I'm making a mobile app using phonegap. That is to say, it's all done
I'm making an android application using phonegap. I'm using phonegap's Storage api for querying
Making an adobe flex ui in which data that is calculated must use proprietary
I am making the phonegap android application in html,javascript and jquery.I have made the
I am making an app with PhoneGap 1.3.0 and Jquery Mobile 1.0. To scroll
I'm working on making a Phonegap plugin for Android. When I add the findViewById
Am making a basic phonegap based android app. All working perfectly and using localstorage

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.