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
...
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...
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
...
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...
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...
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()
...
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, and why do they sometimes give the same result and other times behave differently?
...
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...
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...
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 ...
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...
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); ...
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...
A sample bit of code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<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...
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...
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...
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 ) {
...
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?
...
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...