this

How can i call that function inside that anonymous javascript? (TinyMce example)

How can i call test() inside that method? It's possible? (function() { tinymce.create('tinymce.plugins.WrImagerPlugin', { init : function(editor, url) { editor.addCommand('mceWrImagerLink', function() { //--> how can i refer to test() here? }); }, test: function () ...

C++ using this pointer in constructors

In c++, during a class constructor, I started a new thread with 'this' pointer as a parameter which will be used in the thread extensively (say, calling member functions). Is that a bad thing to do? Why and what are the consequences? Edit: my thread start process is at the end of the constructor. Thanks, Gil. ...

this keyword as a property

I know c# well, but it is something strange for me. In some old program, I have seen this code: public MyType this[string name] { ......some code that finally return instance of MyType } How it is called? What is the use of this? ...

question regarding "this" pointer in c++

hello there, i have been given class with int variables x and y in private, and an operator overload function, class Bag{ private: int x; int y; public: Bag(); ~Bag(); //....... //.....etc }; Bag operator+ (Bag new) const{ Bag result(*this); //what does this mean? result.x += new.x; resul...

Can't limit "return false" to parent element only; want children to return true!

Hey everybody - This is my first time here so I hope I don't come off too stupid! I have a very simple jQuery problem: I have a database-generated ul-based navigation and I want list items that contain other lists to toggle showing those contained lists. The (generated) lists look like this (Wordpress code; ignore the Japanese): <div ...

javascript using 'this' in global object

What does 'this' keyword refer to when used in gloabl object? Let's say for instance we have: var SomeGlobalObject = { rendered: true, show: function() { /* I should use 'SomeGlobalObject.rendered' below, otherwise it won't work when called from event scope. But it works when called f...

jquery updating a div in ajax diesnt work properly, when using a variable

hi, i got the following code var zieldiv = $(this).attr('id'); $.ajax({ url: 'index.php?params', type: 'POST', data: { color:thenewcolor, zieldiv:zieldiv }, timeout: 50000, beforeSend: function() { $("#" + zieldiv).css({background: "#" + thenewcolor} ); } }); I use this for ...

autoreferencing this class to use in another for C++

in java we can do this: public class A{ public static void main(String...str){ B b = new B(); b.doSomething(this); //How I do this in c++ ? the this self reference } } public class B{ public void doSomething(A a){ //Importat stuff happen here } } How can I do the same but in c++, I mean t...

referencing desired objects in namespaced functions

I'm having trouble referencing the desired object when I've namespaced functions. No problems here: obj.test = function() { // this == obj } But I'm getting tripped up when I namespace: obj.namespace.test = function() { // this == namespace } In the latter example, I know this references namespace, but I want to reference obj....

Use of 'this' keyword javascript in IE ?

Is there a workaround for Internet Explorer to implement the functionality offered by 'this' javascript keyword to get the dom element that triggered the event? My problem scenario is : I have a variable number of text fields in the html form, like <input type="text" id="11"/> <input type="text" id="12"/> .. I need to handle the...

Return reference from class to this.

Hi, I have the following member of class foo. foo &foo::bar() { return this; } But I am getting compiler errors. What stupid thing am I doing wrong? Compiler error (gcc): error: invalid initialization of non-const reference of type 'foo&' from a temporary of type 'foo* const' ...

Java: static-non-static-this problem

$ javac TestFilter.java TestFilter.java:19: non-static variable this cannot be referenced from a static context for(File f : file.listFiles(this.filterFiles)){ ^ 1 error $ sed -i 's@this@TestFilter@g' TestFilter.java $ javac TestFilter.java $ java TestFilter file1 file2 file3 TestFilter.ja...

Simple javascript to mimic jQuery behaviour of using this in events handlers

This is not a question about jQuery, but about how jQuery implements such a behaviour. In jQuery you can do this: $('#some_link_id').click(function() { alert(this.tagName); //displays 'A' }) could someone explain in general terms (no need you to write code) how do they obtain to pass the event's caller html elments (a link in thi...

[c++] accessing the hidden 'this' pointer

I have a GUI architecture wherein elements fire events like so: guiManager->fireEvent(BUTTON_CLICKED, this); Every single event fired passes 'this' as the caller of the event. There is never a time I dont want to pass 'this', and further, no pointer except for 'this' should ever be passed. This brings me to a problem: How can I asse...

jquery this and other elements

OK, going rond in circles again - I'm sure the answer will be obvious. Just not to me :) I can't seem to specify this as one target amongst a few targets for a function: $(this, "elem1, elem2").doStuff() I just want to doStuff() to a pair of elements, one of which is this. I can only get it to work if I explicitly name the elements, ...

jquery 2 fades complete at the same time

Hello again, just another quick one: I am noticing differences with fadeOut dependant on whether this is a target. Here's my structure. I have rows of data on my page, and each row has two icons. One is an update icon for that row, one is a delete icon for that row. When a user clicks the update icon for a particular row, I want both t...

Can I refer to an object in its constructor?

Can I do the following? public Manager(String userName) { game = new Game(userName); game.addManager(this); } The problem is that I refer to an object (this) in its constructor (before it was actually created). ...

How to use keyword this in a mouse wrapper in right context in Javascript?

Hi, I'm trying to write a simple wrapper for mouse behaviour. This is my current code: function MouseWrapper() { this.mouseDown = 0; this.OnMouseDownEvent = null; this.OnMouseUpEvent = null; document.body.onmousedown = this.OnMouseDown; document.body.onmouseup = this.OnMouseUp; } MouseWrapper.prototype.Subscribe = funct...

that, self or me — which one to prefer in JavaScript?

While coding JavaScript sometimes you store the reference of object this in a local variable for different purposes (to set proper scope, to help code obfuscators, etc.). There are coders who prefer aliasing this to that to make it obvious its intention. Other guys use self since it's pointing to the object itself. I even saw source code...

Javascript this points to Window object

Hi, I have the following code. I expected to see "archive" object on my firebug console, but I see Window object. Is it normal? var archive = function(){} archive.prototype.action = { test: function(callback){ callback(); }, test2: function(){ console.log(this); } } var oArchive = new archive(); oArchi...