this

How can you use $this reffering to the controller in a codeIgniter model

Hi everyone, I am using CodeIgniter, and in one of my models I would like to refer the $this which is used in $this->load->model and $this->load->view, instead of the $this which refers to the object itself. Is it possible? Thanks, Lemiant ...

How do I pass the this context to a function?

I thought this would be something I could easily google, but maybe I'm not asking the right question... How do I set whatever "this" refers to in a given javascript function? for example, like with most of jQuery's functions such as: $(selector).each(function() { //$(this) gives me access to whatever selector we're on }); How d...

Jquery - Expand image height and width 20% on hover

Evening all - Whats the best way to access an image's height and width dynamically . I want to add 20% to an images width and height and animate when the surrounding div is hovered, I guess I need to use 'this', but not sure how to access the image. Any help greatfully received. Cheers Paul ...

Difference between $(this) and this in jquery

What is the fundamental difference between using $(this) vs this $('.viewComments').click(function(ev){ //returns the desired value alert(this.getAttribute('id')); //Gives an error sayin function is not defined alert($(this).getAttribute('id')); //returns the desired value alert($(this).attr('id')); }); What...

identify select drop-down text using jquery $(this)

I've got several select elements on a page e.g. <select class="dd" id="dropdown1"> <option value="123">Option A</option> <option value="234">Option B</option> </select> <select class="dd" id="dropdown2"> <option value="456">Option C</option> </select> etc etc I would like to use jquery's $(this) to identify which of the s...

C# StyleCop - Using "this." prefix for base class members like current class members or not?

StyleCop has a rule about using "this." prefix to calling class members (SA1101). Is this rule holds true about a member (for example a method) of a class which is inherited from its base class. Example: class BaseClass { protected void F1() { ... } } class ChildClass : BaseClass { protected void F2() ...

How do I use jquery to adjust slideshow captions on the fly?

Hi, I'm still learning jquery and javascript so please bear with me. I've used a tutorial in jquery to create a slideshow using jquery's cycle function. It's great and allows me to rotate individual divs containing an image and a caption. $(document).ready(function() { $('#gallery').cycle({ fx: 'scrollRight', timeout: 5000, ...

What's the difference between $(this) and this in jQuery?

What's the difference between $(this) and this in jQuery, and why do they sometimes give the same result and other times behave differently? ...

How to convert a javascript string to a javascript function, preserving the correct "this"?

A browser element has an onpopupshowing attribute, which is a string consisting of several javascript statements. I want to "override" that bit of javascript. Were this a function, I'd just assign it to a variable, assign my "overriding" function to the element attribute, and (if need be) call the original function from my overriding o...

Jquery slidedown first child level elements

I have one class of divs ('open') the contain another class of divs ('items') like this: <div class="open"> <div class="item"> this is a test 1 </div> <div class="item"> this is a test 2 </div> </div> What I'm looking to do is a slidedown of all the 'item' class divs that are in the 'open' class that's clicked...

What is the difference between $(this) and this

I have the following code $('a').click(function() { var url= this.href; alert(url); }); This works just fine and sure enough the returned result is the url of a tag. However if I change the above code to $('a').click(function() { var url= $(this).href; alert(url); }); The result is undefined. Anyone please help to clear this out ...

C++ instantiate function template as class member and using "this" pointer

Hello, I have two classes (ClassA and ClassB) who both have two methods (compare and converge). These methods work exactly the same way, but these classes are not related polymorphically (for good reason). I would like to define a function template that both of these classes can explicitly instantiate as a member but I'm getting error...

How to set object property in prototype function (scope problem)?

This is something trivial, which I've forgotten. There are possibly duplicates - I searched a little, found similar, but couldn't find as concise. String.prototype.test = function(){this.bar = this.length + 2;} var str = "foo"; str.test(); console.log(str); // foo console.log(str.bar); ...

Is `this` keyword optional when accessing members in C#?

I notice that if you have a private member in a class, you can access it in the class methods by just referring to it's name. You do not need to say this.memberName, just memberName works. So is the this keyword optional in the context of member access? I do see it is useful when you want to clarify the scope - when you have 2 variables...

Javascript and JQuery "this" scope errors

A sample bit of code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt; <div id="myinfo">info</div> <input id="clickme" type="button" value="click here to display info"/> <script type="text/javascript"> function Fighter() { this.name = "Kenny"; // fight...

what does $this mean within a class definition?

As I continue to try and improve myself as a junior PHP developer, I have started to try break down other peoples work. I find it helps me understand, as well as giving me ideas. Two things I do not get, in a PHP class, what $this means, and what array($this,'some_function') means when I would expect a function name in it's place. Many...

Using the "This" Pointer in c++

I've been reading about the "this" pointer on various sites (e.g. the MSDN manuals) and understand its basic uses -- returning a copy your own object or using a pointer of it for returns/comparison. But I came across this statement: // Return an object that defines its own operator[] that will access the data. // The temp object is...

Launching jQuery inside object method

Hello, let's assume that we have object like this below: function foo( some_var ) { this.some_var = some_var; } Now we add some method via prototype: foo.prototype.method = function( value ) { this.some_var += value; } Then, we have method with which I have some problems: foo.prototype.problematic = function( args ) { ...

Can "this" ever be null in Java?

Saw this line in a class method and my first reaction was to ridicule the developer that wrote it.. But then, I figured I should make sure I was right first. public void dataViewActivated(DataViewEvent e) { if (this != null) // Do some work } Will that line ever evaluate to false? ...

How does an object reference itself in Javascript?

I was experimenting with inheritance in javascript, and wrote those two functions: Object.prototype.inherits=function(obj){this.prototype=new obj;} Object.prototype.pass=function(obj){obj.prototype=new this;} This code works very well: Dog.inherits(Animal); But the following fails: Animal.pass(Dog); As I understand it, my pass f...