this

Using this inside a static function fails

I have this method that I want to use $this in but all I get is: Fatal error: Using $this when not in object context. How can I get this to work? public static function userNameAvailibility() { $result = $this->getsomthin(); } ...

In jQuery, how do you resolve the scope of "this", when you are in the scope of each()?

I've created an Object, and have a method setup() in the object. this.debug = function (){...} this.setup = function(){ var fieldsets = form.children("fieldset"); fieldsets.each(function(){ this.debug($(this).attr("class"))); }); } I'm trying to call this.debug which is in the scope of the Object but not in...

Proper usage of "this." keyword in C#?

Hi all, I'm working through the book Head First C# (and it's going well so far), but I'm having a lot of trouble wrapping my head around the syntax involved with using the "this." keyword. Conceptually, I get that I'm supposed to use it to avoid having a parameter mask a field of the same name, but I'm having trouble actually tracking ...

using 'this' and ':not' together in jquery

Hi. I have this line of code $(this).append("<b></b>") and I want to add a :Not condition to it. The best I could reach until now is $(this:not('.someClassName')).append("<b></b>") but of course it's not working. What can I do? Cheers. ...

Assigning scope amongst jQuery.getJSON and a JS.Class

I'm trying to assign some JSON data to a property of a JS.Class instance. var MyClass = new JS.Class({ initialize: function(uuid) { this.uuid = uuid; }, write: function() { $.getJSON(url+"?callback=?", {}, function(data) { Assign(data); }); function Assign(data) { this.content = data; }; } }); var m = ne...

jQuery: show the metadata relevant to a file when a particular filename is clicked (show/hide, this object)

I have the following HTML which is a single result which contains a filename and some metadata about the file. I want to hide the table which has class "detail-pane" initially (I know how to do this) and I want to display the panel (of class "detail-pane") that relates to the filename (e.g. H001_abcde_martin_chop.gits) when the filename ...

The different between submit and click

Look at this: $('form).submit(function (event) { $(':input.required').trigger('blur'); var num = $('.warning', this).length; alert(num);//Focus here! if (num) { event.preventDefault(); }; }); if there're 5 required textbox is empty,then when click the submit button[ID:button1], ...

this === window in firebug

Hi guys, I wrote a simple webpage as follows: <!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>pop</title> </head> <body> <script type="text/javascript" charset="utf-8"> document...

When should I use "this" in a class?

I know that this refers to a current object. But I do not know when I really need to use it. For example, will be there any difference if I use x instead of this.x in some of the methods? May be x will refer to a variable which is local for the considered method? I mean variable which is seen only in this method. What about this.method(...

Quick php question about ordering row results

Hello all, Consider the following : $img_pathm = JURI::root().'images/properties/images/'.$this->datos->id.'/'; $peque_path = JURI::root().'images/properties/images/thumbs/'.$this->datos->id.'/'; $result = count($this->Images); $resultf = $result-1; while ($resultf>=0){ ?> <span class="editlinktip hasTip" title="<?php echo $this->da...

Java - when to use 'this' keyword

What is the best practise for using the this keyword in Java? For example, I have the following class: class Foo { Bar bar; public Foo(Bar bar) { this.bar = bar; } } That's fine and all, but Java is clever enough to know what is happening if I change the statement in the constructor to bar = bar; So why use t...

Why this method does not use any properties of the object?

Here I found this code: import java.awt.*; import javax.swing.*; public class FunWithPanels extends JFrame { public static void main(String[] args) { FunWithPanels frame = new FunWithPanels(); frame.doSomething(); } void doSomething() { Container c = getContentPane(); JPanel p1 = new JPan...

Macro to improve callback registration readability

I'm trying to write a macro to make a specific usage of callbacks in C++ easier. All my callbacks are member functions and will take this as first argument and a second one whose type inherits from a common base class. The usual way to go is: register_callback(boost::bind(&my_class::member_function, this, _1)); I'd love to write: re...

How to use "this" and not "this" selectors in jQuery

I have 4 divs with content like below: <div class="prodNav-Info-Panel">content</div> <div class="prodNav-Usage-Panel">content</div> <div class="prodNav-Guarantee-Panel">content</div> <div class="prodNav-FAQ-Panel">content</div> And a navigation list like this: <div id="nav"> <ul id="navigation"> <li><a class="prodNav-Info" ></a>...

Use this. to access internal class members?

On the internet I see a lot of code which uses this. to access local members of a class, like this: private String _whatever; public String Whatever { get { return this._whatever; } set { this._whatever = value; } } public void DoSomething() { String s = this.Whatever; this.DoSomething(); } (don't expect the c...

Why doesn't the compiler at least warn on this == null

Why does the C# compiler not even complain with a warning on this code? : if (this == null) { // ... } Obviously the condition will never be satisfied.. ...

Javascript function objects, this keyword points to wrong object

I've got a problem concerning the javascript "this" keyword when used within a javascript functional object. I want to be able to create an object for handling a Modal popup (JQuery UI Dialog). The object is called CreateItemModal. Which i want to be able to instantiate and pass some config settings. One of the config settings. When th...

jQuery remove selected option from this

Hi all, first post here, I come in peace :) I've searched but can't quite find what I'm after. I am trying to manipulate the selected option of a select box. Can someone please explain why this works: $('#some_select_box').click(function() { $('#some_select_box option:selected').remove(); }); but this doesn't: $('#some_select_box'...

[Using $this when not in object context in] php error

I have solved this problem, I just need to know what to do. I get the above error because I just realised that the class is being run as class::function($values) instead of class->function($values). Does anyone know how to convert this function to instantiate the class then run the function with values? private function _load($values=n...

What is an "incompletely constructed object"?

Goetz's Java Concurrency in Practice, page 41, mentions how this reference can escape during construction. A "don't do this" example: public class ThisEscape { public ThisEscape(EventSource source) { source.registerListener( new EventListener() { public void onEvent(Event e) { ...