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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:11:41+00:00 2026-05-23T22:11:41+00:00

I have the following widget var a = $(‘#test’).timetable({ cell_click: openDialog }); whereby cell_click

  • 0

I have the following widget

var a = $('#test').timetable({
            cell_click: openDialog
        });

whereby cell_click is an event generated by

_create:function(){ 
    dayBodyCells.click(function(){
            if( !$(this).hasClass('cell-inactive') ){
              var dic = self.getElementPos(this);
              self._trigger('cell_click', null,dic);        
        }
    });

and openDialog is the callback function. In the callback function for the dayBodyCells, i have this equaling the td element, which is what i expected. I’m curious – why does this inside function openDialog instead refers to #test?

  • 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-23T22:11:41+00:00Added an answer on May 23, 2026 at 10:11 pm

    Within a bound event handler (callback), this refers to the element on which the event was triggered. So:

    $('#myid').click(function(){
        // this is the #myid element
    })
    

    In your code, dayBodyCells must be a td (as you expect) therefore this refers to it in the click handler. However, when you trigger the cell_click event, you must be firing it from the #test element (via self._trigger).

    If self._trigger('cell_click', null,dic) were replaced with $(this).trigger('cell_click', null,dic), this would then refer to the td within openDialog

    Have a look at http://www.pkshiu.com/loft/archive/2009/01/understanding-this-this-and-event-in-a-jquery-callback-function and http://api.jquery.com/category/events/

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

Sidebar

Related Questions

I have the following code: dijit.byId('patient').onchange(function(event){ var term=dijit.byId('patient').get('value'); patientList.url = .calendar/search-patient?term=+term; patientList.close(); }) What
I have the following Javascript between tags in a template: YAHOO.util.Event.addListener(window, load, function() {
I have the following image which I need to turn into an HTML widget
i have the following jquery code to format a html table. $(.jtable td).each(function() {
I have stolen/found/used/written and edited the following widget of jQuery for a auto-completing dropdown.
I have the following variable series : var series: List[FlotSerie] = List( new FlotSerie()
I have the following codes to create chart graphics by dojox.charting: function createChart() {
i have the following function in jQuery and javascript that creates a form element:
hey guys, i did the following function in order to have the same height
js undefined error we have the following widget code : index.html <script type=text/javascript language=javascript>

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.