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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:20:15+00:00 2026-05-24T01:20:15+00:00

How would I get to call the method showAlert() I have tried storing a

  • 0

How would I get to call the method showAlert() I have tried storing a reference to the plugin with this and $(this) inside the self variable but none seem to work. I’m calling the showAlert from inside the button click event.

 (function($){

      //Add your default settings values here
      var settings = {
        //Replace with your own settings
        testValue:"FOO"
      }

      var selectedArr=[];
      var self=this;

      var methods = {
        init : function(options){
          return this.each(function(){
            //if options exists, let's merge them with our default settings
            if(options){
              $.extend(settings,options);
            }

            var $this=$(this);
            var button = $this.find('.schedule .time a');

            button.click(function(evt){
                evt.preventDefault();
                selectedArr.push( $(this).addClass('selected') );
                $(this).parent().find('input').attr('checked','checked');
                self.showAlert();
            })
          });
        }
      }

        showAlert: function(){
            alert("Please select an alternitive");
        }

      //Setting namespace. Under no circumstance should a single plugin ever claim more than one namespace in the jQuery.fn object. 
      //See http://docs.jquery.com/Plugins/Authoring for an explaination of the method used here
      $.fn.chooseAppointment = function(method){

        if(methods[method]){
          return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
        }else if(typeof method === 'object' || !method){
          return methods.init.apply(this,arguments);
        }else{
          $.error('Method ' + method + ' does not exist on jQuery.chooseAppointment');
        }
      };

    })(jQuery);
  • 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-24T01:20:16+00:00Added an answer on May 24, 2026 at 1:20 am

    The way you have it written, showAlert isn’t a member of this or self. Just declare showAlert before the methods variable like this:

    var showAlert = function() { alert("Please select an alternitive"); };
    var methods = { /* etc etc */ };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to make the parameters of this extension method 'intellisensible' from
Not sure what the best title would be for this question, or even if
I have a WEIRD problem with Future.get() in Java. It returns always with an
Here's the premise: I have many classes where I need to perform an action
I am reading the MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework—Application Development
I've downloaded PHPExcel 1.7.5 Production . I would like to use setReadDataOnly() and enableMemoryOptimization()
I'd like to make a delegate that invokes a specific instance method, unfortunately, it
I have created an application that searches a directory and loads all of the
Am I right in saying there is no Intellisense for C# 4 named parameters
IMHO, there are two techiques to handle a query for a resource: For http

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.