this

How to set callback on single items using jQuery

I have a js function which has, until now, always been the callback for a click event, and therefore relies heavily on the 'this' pseudo-variable. 'this' is a <li> element. However I now have a circumstance where it is sometimes triggered using more convoluted route, and in these circumstances 'this' is an entirely different element. Ho...

Problem with "this.function" and Scope in my code

Hey I have this code right here: http://pastie.org/534470 And on line 109 I get an error saying "TypeError: Result of expression 'this.allVarsDefined' [undefined] is not a function." Scope in javascript is confusing to me. Can anybody see what my problem is? Also do you guys know of any articles that would help me learn about scope in ...

Access "this" from Java anonymous class

Given the following code: public interface Selectable { public void select(); } public class Container implements Selectable { public void select() { ... } public void createAnonymousClass() { Selectable s = new Selectable() { public void select() { //see comment below. } }; } } I want to acces...

this = this in decompiled Java

I tried decompiling a Java application to which I do not have the source code and a strange thing showed up. At the top of the constructor for a class, there is a line that says this = this What does this (not this) mean? Is this just an artifact of the decompilation process? Or is it just some ugly hack? Can this be assigned to s...

Overhead when using keyword this?

The scope of my question is solely ASP.NET, as the answer may be different for Java and any other C based language. How much overhead is involved when using the keyword "this" within a class to dereference a property? It seems that I've seen certain sources try to discourage the use of "this" for dereferencing, but generaly I've just ig...

returning functions as string in javascript

hello, I am in the process of writing a javascript object that contains a method that returns the html of a standard form. In this object I also have a method validate(); I'd like the form generated to use validate(); So the typical html of a form with validation would probably look like this: <form id="a" onSubmit="return validate();"...

hi everyone, what do these "this" mean in this simple javascript program?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <script type="text/javascript" charset="utf-8"> (function(){ /...

Getting correct "this" in jQuery button callback

I have a class: function RustEditor() { this.init = function() { var saveButton = this.container.find("button.saveButton"); saveButton.click(function(){this.save();}); }; ... When I click the button, it complains that this.save is not a function. This is because "this" does not refer to the instance of RustEditor here, but to the...

Using "this" in front of member variables in C++

Possible Duplicates: Is excessive use of this in C++ a code smell Given that most organizations have a coding standard for member variables like "m_memberVar" or "memberVar_", are there good reasons to use "this->memberVal" format instead? Is there any reason not to? ...

jQuery $this vs $(this) in plugin development

I was wondering why in so many jquery plugins $(this) is set to be pointing at $this, here is an example, if i have the following two plugins included on a page: (function($) { jQuery.fn.pluginOne = function() { return this.each(function() { $this = $(this); <-- alert($this); }); }; })(jQuery) (funct...

Are there equivalents to "this" for static variables in c#

I was wondering if I can make my code clearer by indicating one variable is a static class variable. If it wasn't static I could use this.variableName, and everyone would look at it and immediately know that. I know I could adopt a naming convention like s_variableName, but that seems a little odd to me and increases the learning curve ...

Scoping "this" in Javascript (and jQuery.extend)

Sorry if this has been answered, but I couldn't turn up a search for it... a difficult thing to search for, I think! Say I have this: var MyPrototype = function() { this.init(); } $.extend(MyPrototype.prototype, { a: 5, init: function() { var thing = new SomeOtherClass(); thing.meth = this.meth; // thing...

How does 'this' work in JavaScript?

I know there are several other posts on this topic but they still leave me confused. I've included jQuery and everything and, I have a simple javascript class like this example: function CarConstructor(){ this.speed=19; // in mph this.make="Ford"; this.fillKph=fillKph; } function fillKph(){ $("#kphdiv").html(this.speed*1.61); ...

How to improve this code using $(this) in jQuery?

I have the following jQuery function (simplified): function doSomething(el, str) { el.find('.class').text(str)); } Don't worry about the .text() part, in reality I'm doing something a bit more complicated than that... But since that's irrelevant to my question, I'm just using .text() here as a simple example. The problem is, everyti...

Is it OK to use "delete this" to delete the current object?

I'm writing a linked list and I want a struct's destructor (a Node struct) to simply delete itself, and not have any side effects. I want my list's destructor to iteratively call the Node destructor on itself (storing the next node temporarily), like this: //my list class has first and last pointers //and my nodes each have a pointer to...

How can I maintain control of the this keyword when extending prototypes in jQuery?

I'm implementing a class-like structure in jQuery, but I'm having some trouble when I try to call some of my functions. This is how the structure is setup: MyClass = function(name) { this.init(name); } $.extend(MyClass.prototype, { init: function(theName) { this.myFunction(); // works $('.myclass').each(function(){ ...

how to get to the value of manipulated dom element using _this_ Jeditable?

This is a Continuation of http://stackoverflow.com/questions/1255596 Please respond here.. this is my 'real' account.. I'm trying to assign different parameter values to different divs on which I have enabled the jQuery plugin 'Jeditable'. I can't get it to work, I'm sure its something simple.. but I can't figure it out.. How do I ach...

What is 'this' before an object is instantiated in js?

I don't understand the following: var x = function() { this.foo="foo"; return function() { this.bar = "bar"; return foo+bar; }; }(); // returns inner alert(x()); // 'foobar', so both 'this' variables are set alert(x.bar); // undefined - but wasn't it used correctly? alert(new x().bar); // ok, works My assumption was that a def...

The C++ implicit this, and exactly how it is pushed on the stack.

Hi: down to business: I need to know whether, when a class method in C++ is called, the implicit 'this' pointer is the first argument, or the last. i.e: whether it is pushed onto the stack first or last. In other words, I'm asking whether a class method, being called, is taken by the compiler to be: int foo::bar(foo *const this, int a...

JQuery and 'this' object

I have the following JQuery function being attached to the blur event of n textboxes on a webpage. $(document).ready(function() { $("input[id$='_txtTuitionAmt']").blur(function() { alert(this.value); }) }); It works just fine. When the user tabs out of any of the textboxes then an alert popups and displ...