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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:04:15+00:00 2026-05-25T10:04:15+00:00

Hello Stackoverflow users, I have a question regarding an JQ UI widget im trying

  • 0

Hello Stackoverflow users,

I have a question regarding an JQ UI widget im trying to make.
I have a _create command with the following:

    this.findinput =    this.element.children('input:text')
                            .addClass('ui-search-input ui-widget ui-state-default ui-background-none ui-corner-left')
                            .wrap('<div class="ui-position-wrapper" />')
                            .bind('focusin focusout',this._checkval)
                            .bind('keyup',this.inputchanged);

As you can see i bind some function to the input field, so i can manipulate the text and layout.
But my problem is that the function is for some reason overwriting the globa object ‘this’ and its variables.
How can i keep them inside the functions?
(The reason i use functions is so i can acces them from outside the widget)

inputchanged: function(e) {
    $target = $(e.target);
    if (($target.val()).length != 0) {
        this.element.children('.ui-search-reset').children().addClass('ui-icon').removeClass('ui-helper-hidden');
    } else {
        this.element.children('.ui-search-reset').children().addClass('ui-helper-hidden').removeClass('ui-icon');
    }
},

returns: this.element is undefined and i cant acces this.options either?

Also if i bind a function to a “tr” in a table, and press the “td” it sets the “td” as the target object instead of the “tr”, which where the one binded – why is this? 🙂

Im quite new to jQuery so this might be stupid questions, or i might be doing it wrong – please let me know if that is the case!

  • 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-25T10:04:16+00:00Added an answer on May 25, 2026 at 10:04 am

    An easy way to make sure you get the right this is to do it explicitly:

    var self = this;
    this.findinput = this.element.children('input:text')
                         //...
                         .bind('focusin focusout', function(e) { self._checkval(e) })
                         .bind('keyup', function(e) { self.inputchanged(e) });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I'm trying to make option for users to login to my site with
Hello good people of stackoverflow, this is a conceptual question and could possibly belong
Hello fellow Stackoverflow users, I have a page which does a AJAX request to
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello Stack Overflow Experts, i have need of your expertice: I am trying to
Hello stack overflow I need help with this problem. Ok, I have a flat
Hello fellow StackOverflow users (or Stackoverflowers ?): I'm learning-by-coding WPF. I read several articles/saw
Why hello there Stackoverflow, I have a nutcracker for ya, is there an good
Possible Duplicate: Copy a linked list Hello stackoverflow! I am trying to learn more

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.