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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:44:02+00:00 2026-06-04T12:44:02+00:00

I’m running a touch event test with Modernizr, the test seems to be running

  • 0

I’m running a touch event test with Modernizr, the test seems to be running fine, but still a function I’m calling only if the test is successful it’s called.

This is the test :

Cluster.prototype.test_touch_event_support = function(callback) {
    return (Modernizr.touch) ? callback : log("Touch Support Undetected");
};

And this is the function that should run only if the test is successful :

Cluster.prototype.initiate_shop_touch_events = function() {
    var self = this;
    return $("#" + this.shop_wrapper_id).hammer({prevent_default: true, drag_min_distance: Math.round(this.viewport_width * 0.1)}).bind("drag", function(ev) {
        var data = JSON.parse(self.get_local_storage_data(self.shop_data_key));
        var step = (ev.direction == "left") ? 1 : -1;
        var new_page = parseInt(data.current_page + step);
        return (new_page > 0 && new_page <= data.total_pages) ? $(self.shop_navigation_class).jPages(new_page) : false;
});
};

And I’m checking like so, even though it doesn’t depend on the argument I’m passing to the test :

self.test_touch_event_support(self.initiate_shop_touch_events());

Can someone tell me why the function is still running ? Because I also get in the console the message that touch events are not supported.

  • 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-04T12:44:04+00:00Added an answer on June 4, 2026 at 12:44 pm
    self.test_touch_event_support(self.initiate_shop_touch_events());
    

    will pass the result of calling self.initiate_shop_touch_events to self.test_touch_event_support

    You need to do :

    self.test_touch_event_support(self.initiate_shop_touch_events);
    

    To pass the function.

    In

    Cluster.prototype.test_touch_event_support = function(callback) {
        return (Modernizr.touch) ? callback : log("Touch Support Undetected");
    };
    

    You need to call the callback not reference it.

    Cluster.prototype.test_touch_event_support = function(callback) {
        return (Modernizr.touch) ? callback.call (this) : log("Touch Support Undetected");
    };
    

    Lessons to take away:

    1. Understand the difference between calling a function and referencing it. Unlike in many programming languages, functions in JavaScript are first class entities. Your can pass around references to them by invoking their name. To invoke, call or execute a function you must specify a, possibly empty, list of arguments enclosed in brackets immediately after the function reference.
    2. When invoked, all functions are passed a context parameter referenced using the word this in the function body. This is often specified by preceding the function name with an object reference e.g. obj.func (123) On this call the object obj will be used each time the function body references this. With this usage, the function must be a defined method of the object. The call and apply methods of functions can be used to explicitly specify this context argument : func.call (obj, 123) is the equivalent to the above when func is not a method of obj.

    More details can be found here https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.