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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:55:43+00:00 2026-06-12T21:55:43+00:00

function Class() { var self=this; self.searchfield=$(‘#search’); self.resultbox=$(‘#searchresults’); self.onSearchFieldChanged=function() { console.log(F: +self.searchfield); console.log(R: +self.resultbox); }

  • 0
function Class() {
    var self=this;
    self.searchfield=$('#search');
    self.resultbox=$('#searchresults');

    self.onSearchFieldChanged=function() {
        console.log("F: "+self.searchfield);
        console.log("R: "+self.resultbox);
    }
    self.searchfield.live("keyup",self.onSearchFieldChanged);
}
var INSTANCE=null;
Class.init=function() {
   INSTANCE=new Class();
}
$(document).bind("globalsloaded", Class.init);

As soon as I type something in #search input, the output on console is as following:

F: undefined
R: undefined

So why are those two variables undefined? They ARE in scope and should contain the corresponding jQuery objects.

  • 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-12T21:55:45+00:00Added an answer on June 12, 2026 at 9:55 pm

    After 5 days of work I found the Problem: JQueryMobile

    What happens is:

    1. deviceready event by phonegap
    2. domready event
    3. My init is called
    4. JQM extracts the input#search element to reinsert it again, surrounded by some style divs
    5. The div I saved in my init is no longer valid, as refers to the “old” dom element

    Now I am doing my initialization in the pageinit event of JQM. No problems anymore.

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

Sidebar

Related Questions

Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
I have a class: function RustEditor() { this.init = function() { var saveButton =
In this code: <?php class Foo { var $value; function foo($value) { $this->setValue($value); }
I have an array of function callbacks, like this: class Blah { private var
<html> <head> <script> function SuperClass() { var self = this; self.someVariable = true; }
I am having trouble with the following code: function Class() { var self =
In JavaScript I'd set up a class like: var SomeClass = (function() { var
I created a javascript class as follow: var MyClass = (function() { function myprivate(param)
I have the following class in a php file: function calcTotal(){ var productID =
I tried this example code: class testclass: classvar = 'its classvariable LITERAL' def __init__(self,x,y):

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.