I grabbed this code form some book I've bumped on the InternetS...
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: {
fn: function(sm,index,record) {
Ext.Msg.alert('You Selected',record.data.title);
}
}
}
});
now, sm is shorthand for selection...
I generally write code that looks like this (but with many more handlers).
$(document).ready(function() {
$("#next").click(function() {
doStuff();
});
$("#prev").click(function() {
doSomeOtherStuff();
});
$("#link").hover(function() {
doSomeTotallyOtherStuff();
});
});
Is this the bes...
I am wondering if anyone knows why some people define global variables that are set to functions vs just defining a global function name. For example:
var foo = function() { alert('hello!'); }
instead of
function foo() { alert('hello!'); }
Wouldn't the second method be better since there is a chance something might overwrite the f...
Hi, on a website i want to do this: (simplified)
myHandlers = new Array();
for(var i = 0; i < 7; i++) {
myHandlers.push(new Handler({
handlerName: 'myHandler'+i, // works, e.g. ->myHandler1, 2, 3 etc.
handlerFunc: function(bla) { /*...*/ alert(i); } // doesn't work,all return 7
}
}
I could set the counter as another attrib...
I was reading that using anonymous functions in javascript is bad practice, because it can make debugging a pain, but I haven't seen this for myself. Are anonymous functions in JavaScript really bad practice and, if so, why?
...
Hi,
I'm working with a fairly complex Javascript program wich, at a given point, returns some nested anonymous functions.
Sometimes, when I try to "apply" one of such anonymous functions ("f" in this example)...
f.apply (this.context, args)
...I get an "f.apply is not a function" error.
It's weird, because alert(f) displays the fun...
Getter functions allow obj.meth syntax instead of obj.meth(), I'd like to create an anonymous one of these to return from another function. function get ():Object { } is invalid syntax. I don't suppose Flex offers an easy way to get this functionality, if it's even possible?
...
Currently, I have a static factory method like this:
public static Book Create(BookCode code) {
if (code == BookCode.Harry) return new Book(BookResource.Harry);
if (code == BookCode.Julian) return new Book(BookResource.Julian);
// etc.
}
The reason I don't cache them in any way is because BookResource is sensitive to cultu...
class Test:
def somemethod(self):
def write():
print 'hello'
write()
x = Test()
x.somemethod()
write() is a function that will be used several times through somemethod(). somemethod() is the only function within the class that will require it's use so it seems silly to define it outside of somemethod(...
Both Eclipse and NetBeans throw errors about the use of anonymous functions. The error in NetBeans says The language feature not compatible with PHP version indicated in project settings
The code is working but the IDEs don't seem to like it. Should I be worried?
...
Is there an alternative to anonymous functions for versions of PHP previous to 5.3.0?
...
Why this doesn't work in Firebug console:
function(s,e) {
setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
}
While this does:
setTimeout(function(){grvClosingDocs.Refresh();CBPDocFlow.PerformCallback();},100)
...
I understand that there are special actions to maintaining the lifetime of a outer variable when it was mentioned inside an anonymous procedure. But when the anonymous procedure doesn't use outer variables, will it generate the same assembly call as the good old general procedure. In other words, will the internals of the anonymous funct...
mysub gets a subroutine reference as its first argument.
Can I simply call mysub(sub{some subroutine body here}) ? I.e. define an anonymous subroutine right at the call?
Is the syntax OK (is it really a reference to sub that is passed)?
...
My intuition is that it's a good idea to encapsulate blocks of code in anonymous functions like this:
(function() {
var aVar;
aVar.func = function() { alert('ronk'); };
aVar.mem = 5;
})();
Because I'm not going to need aVar again, so I assume that the garbage collector will then delete aVar when it goes out of scope. Is this rig...
Hi,
I asked a related question before I lost my login id - http://stackoverflow.com/questions/3723748/php-version-5-2-14-parse-error-syntax-error-unexpected-t-function-expecting - but this is the "entire" problem.
I'm having a hard time figuring out how to convert this function (got from somewhere on SO) to work with PHP 5.2.14 (which ...
Possible Duplicate:
Location of parenthesis for auto-executing anonymous JavaScript functions?
Sometimes I see:
(function() { ... }());
and sometimes I see:
(function() { ... })();
I see both forms with and without arguments. They both execute the anonymous function.
Is there a difference between the two forms? Are t...
Hi,
I have some PHP 5.3 code which builds an array to be passed to a view. This is the code I have.
# Select all this users links.
$data = $this->link_model->select_user_id($this->user->id);
if (count($data) > 0) {
# Process the data into the table format.
$table = array
(
'properties' => array
(
...
I want to do something similar to this:
def creator()
return lambda { |arg1, arg2 = nil|
puts arg1
if(arg2 != nil)
puts arg2
end
}
end
test = creator()
test('lol')
test('lol', 'rofl')
I get a few syntax errors:
test.rb:2: syntax error
re...
Hi. I'm new to javascript and I am looking through some Raphael demo code. I'm confused by how this is working...
if (R) {
(function (dx, dy, R, value) {
var color = "hsb(" + [(1 - R / max) * .5, 1, .75] + ")";
...
From what I can see this is declaring an anonymous function which takes 4 arguments. How is this function inv...