var User = {
Name: "Some Name", Age: 26,
Show: function() { alert("Age= "+this.Age)};
};
function Test(fn) {
fn();
}
Test(User.Show);
===============
Alert shown by code is "Age= Undefined". I understand as User.Show function is called from inside of Test(), refers 'this' of 'Test()' function rather than 'User'...
Hi,
I'm trying to assign a different number to different callback functions in jquery.
for (i=o;i<types.length;i++) {
$('#ajax'+types[i]+'Div').html('Loading...').load('searchAjax.php','new=u',function () { $(this).find('select').change( function() { AjaxDiv(i); } ) } );
}
Everytime I run this section of code, i is 5 for each c...
I have a problem with Haskell's scoping in where definitions. When I have the following function f, where I want to pass the x to the locally defined function f1 without explicitely using it as a parameter, I get an error saying that the type of x is incompatible with the one in the output of f1, although it should be the same:
f :: Eq...
I have heard about the following scenario right when I started programming in C.
"Trying to access from outside, a functions local variable will result in error (or garbage value). Since the stack gets cleared off when we return from the function"
But my below code sample prints a value of 50. I am compiling the code with latest GCC c...
If I have an ActiveRecord::Base model with a default-scope:
class Foo < ActiveRecord::Base
default_scope :conditions => ["bar = ?",bar]
end
Is there any way to do a Foo.find without using the default_scope conditions? In other words, can you override a default scope?
I would have thought that using 'default' in the name would sug...
I wonder if there's a way to define a class in such a way that instances of it will never be members of another class (only local variables), or the other way round - only members but never local.
Is there any way in which a class can dictate the scope of it's prospective instances?
...
I'm implementing callback routines for external static C++ library to be used in Objective-C project. Now I have trouble moving data between callback and normal routines. As you can see below my "msgStore" is defined as part of MyMessage class and can be used within class routines such as init(). However attempting same from callback rou...
Hi I'm trying to reuse some code i was pointed to earlier to run a 3rd party .exe inside of a my winform
the code i was given was
via Mr. Greg Young
public class Native {
[DllImport("user32.dll", SetLastError = true)]
private static extern uint SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public static v...
Code snippet as follows:
$(this).parents('td:first').next().find('option').customizeMenu('myMenu2');
This works,but :
var listener = function(){
$(this).parents('td:first').next().find('option').customizeMenu('myMenu2');
};
listener();
is not working,why and how to fix it?
...
afternoon all.
i am working on a project written on rails 2.1
in newer versions we can use a rather cool method to create a default scope like so
default_scope :order => 'title ASC'
how can the same/similar effect be achieved without upgrading the rails version?
...
I have two questions.
In C++, a static member function has direct access to a public non-static data member defined in the same class?
False
In C++, a non-static member function has direct access to a private static data member defined in the same class?
True
My note say false for the first question and true for the second one. I jus...
I'm trying to port some code from VC9 to G++, however Ive run into a problem with template specialisations apparently not being allowed for class members.
The following code is an example of these errors for the getValue specialisations of the class methods. In all cases the error is "error: explicit specialization in non-namespace scop...
I have a for loop, and inside it a variable is assigned with var. Also inside the loop a method is called which requires a callback. Inside the callback function I'm using the variable from the loop. I would expect that it's value, inside the callback function, would be the same as it was outside the callback during that iteration of the...
Have next script:
function clicker(){
var linkId = "[id*=" + "link]";
var butnId='initial';
$j(linkId).click(function(){
var postfix = $j(this).attr('id').substr(4);
butnId = '#' + 'butn' + postfix;
});
return butnId;
}
Function output is 'initial' value.
How to return actual value of variable butnId,after it...
Hi, I've been playing around and searching a bit, but I can't figure this out. I have a pseudo private function within a JavaScript object that needs to get called via eval (because the name of the function is built dynamically). However, the function is hidden from the global scope by a closure and I cannot figure out how to reference i...
Setup:
class A {
public:
void a() {}
};
class B {
public:
void b() {}
};
class C: public A, public B {
public:
void c() {}
};
What (I thought) I should be able to do:
C* foo = new C();
foo->b();
And I get the following linker error from GCC:
`... undefined reference to 'C::b(void)'`
If I use explicit scope re...
I am sure someone has gone over this but I have had no luck finding some results.
I want to know what is the fastest way to maintain a proper variable scope.
Here is some example jquery code I wrote this morning.
var oSignup = {
nTopMargin: null,
oBody: $("div#body"),
oSignup: $("div#newsletter_signup"),
oSignupBtn: $("d...
I'm working on writing a tweening class in as2 that has a callback variable and I can't seem to find a good way to get the scope without specifically passing in a scope variable as well. This tweening class needs to work in classes as well as on the timeline. Here's what my codes looks like right now.
params.scope[ params.onComplete ]( ...
I just discovered that the Me keyword cannot access private procedures even when they are inside its own class model.
Take the following code in Class1:
Private Sub Message()
Debug.Print "Some private procedure."
End Sub
Public Sub DoSomething()
Me.Message
End Sub
This code instantiates an instance of the class:
Sub TestCla...
I have a ruby hash:
VALS = { :one => "One", :two => "Two" }
and an Array:
array2 = ["hello", "world", "One"]
Question: How can I populate a new array1 so that it only pulls in any values in array2 that match exactly the values in VALS?
For example, I have tried:
array2.each_with_index do |e,i|
array1 << e if VALS[i] ~= e
end
Alon...