I cannot get the blur() function in the following to work:
$('.newselect').focus(function(){
$(this).parent().append('<div class="select_container"></div>');
});
$('.newselect').blur(function(){
$(this).parent().remove('.select_container');
});
However if I use a universal selector $('*') (as below) it works, why is this and h...
This is probably best explained through some code. I know that in the following example, the this inside the addEvent method is the current element contained in the array elements.
var testClass = new Class({
testMethod: function() {
var elements = $$('.elements');
elements.addEvent('click', function() {
...
I'm new to CakePHP and I'm looking at some code I've downloaded that has a function that looks like this:
$this->set(array('fruit' => 'orange', 'vegetable' => 'kale'));
In the code, the array variables are accessed in another controller function using this method:
$varsSet = $this->viewVars;
echo $varsSet['vegetable'];
What I'd lik...
Why can't the keyword this be used in a static method? I am wondering why C# defines this constraint. What benefits can be gained by this constraint?
[Update]:
Actually, this is a question I got in an interview.
I do know the usage of 'static' and 'this', based on all your response, I guess I know a little of why the two can not be use...
Sometimes it can be confusing reading code in instance members that refers to other instance members of the same class (or a base class):
public void MyMethod()
{
Where = did + AllTheseWeirdThings(GetDeclared()); // ?
}
Having a coding standard something like "prefix all private/protected members with "_" doesn't help, because ins...
I was browsing some documentation for a physics library for XNA and noticed an example someone had used for creating a class for a Car.
This is a pretty simple example:
Class Car
{
private float gravity;
private float maxSpeed;
public Car(float gravity, float maxSpeed)
{
this.gravity = gravity;
this.maxSpee...
class Person
{
string name;
public Person(string name)
{
this.name = name;
}
public void method()
{
Person gupta = new Person("James"); // Current Object
Console.WriteLine(this.name);
Person gupta1 = new Person("Peter"); // Current Object
Console.WriteLine(this.name);
...
I know 'this' differs outside and inside of the closure.
But why numChildren and this.numChildren differs inside the closure?
Or why numChildren is same outside and inside?
var _this:Sprite = this;
trace("[outside]this: " + this);
trace("[outside]numChildren: " + numChildren);
trace("[outside]this.numChildren: " + this.numChildren);
(...
The below works fine. However, I have 2 submenus - if I hover over either, both of their children "ul.menu_body" fade in.
presumably i need to use "this" somewhere, so the fade only applies to the desired menu.
I tried adding
$("ul.menu_body", this).fadeIn('fast')
but this stops it working altogether - no errors mind (that i can see)
...
Hi, I am trying to crate a panorama slider as a jQuery plugin, and I have the following code..
$.fn.panorama = function(settings) {
var myPanorama = this;
..
this.mousedown(function(e){
//do stuff
$(this).css... //this all work
}
//Call mouseup on document in case user lets go of mouse outside dr...
I'm a little confused as to why this doesn't give an error. I found this code deep inside of some outdated legacy software and was surprised to see it work.
public static string CleanFileName(this string fileName)
{
return CleanFileName(fileName, 64);
}
public static string CleanFileName(this string fileName, int maxLength)
{
//so...
Should 'this' in the following code not still refer to the DOM object selected by the MooTools selector?
$$('div').addEvent('click', function()
{
var click1 = function(){$(this).setStyle('background', 'red');}
click1();
});
...
I have this code
$(document).ready(function(){
$('.selector').click(function(){
obj = $(this);
obj.replaceWith('<div class="size">whats up man ??!</div>');
alert(obj.html());
});
});
I want to get the new content of 'obj' that has been 'replaceWith'
but,
I get the old content instead ...
how do I get...
In plain English, how is $this used in PHP?
It's such a simple concept to me in JavaScript, but for some reason in PHP I can't get my head around this variable and its function. What, at any given point, is it referring to exactly? I have only tertiary experience with OOP, and I suspect that's why it's hard for me to understand its usag...
I've been coding with jQuery for about 2 years now but I've never done it in a plugin. I'm trying to change this. I found a few websites that explain how to create a plugin and I understand the basics.
The part that I don't understand is the use of the this keyword. Here's a simple plugin example:
(function($){
$.fn.myPlugin = functi...
I'm having difficulty referencing "this" from within a javascript inline function, within an object method.
var testObject = {
oThis : this,
testVariable : "somestring",
init : function(){
console.log(this.testVariable); // outputs testVariable as expected
this.testObject.submit(function(){
var a...
Hi all,
I'm making a script which has one ajax call inside an each function. The problem is that on the success callback from ajax call, I want to use the object that we are using at each function.
EDIT:
Here is some of my code:
configs={
general:{
max_ads:6},
logs:{
selector:"div#MicrodualGetAd-debug"},
connection:{
...
I have two Javascript "objects" similar to so....
var Object2 = new (function() {
this.FetchData = function(callback) {
// do some stuff
callback(data);
};
});
var Object1 = new (function() {
this.DisplayStuff = function() {
};
this.LoadData = function() {
Object2.FetchData(this.OnData);
...
I'm in a function in java and I create a new Object passing "this" as paramter:
class AClass {
AClass(TestClass testClass) { }
}
class TestClass {
AClass doSomething()
{
return new AClass(this);
}
}
How to do That in C++?
Should be:
class AClass {
AClass(TestClass* testClass) { }
};
class TestClass {
...
I am getting a Fatal error: Using $this when not in object context in Stemmer.php on line 317.
At the moment I am using the Stemmer class which I found on the internet to change words to their stemmed version before searching the database for matches.
I have read all the related posts where people are having a similar problem. The dif...