I'm creating a bunch of dijit.InlineEditBoxes programmatically, and having some trouble with the onChange event. While if you create the editboxes statically, you can set a complex onChange function, ie
Edit me
when creating them programmatically, it seems that the onChange has to be a pointer to a function, and only passes the new value of the editbox; ie
var inlineEdit = new dijit.InlineEditBox({
autoSave:true,
renderAsHtml:false,
onChange:foo
}, dojo.byId(id);
...
function foo(e){
alert(e); // alerts inlineEdit.newvalue;
}and you cannot send parameters to the onChange function, like
var inlineEdit = new dijit.InlineEditBox({
autoSave:true,
renderAsHtml:false,
onChange:foo(arg1,arg2)
}, dojo.byId(id);
...
function foo(arg1,arg2){
alert(arg1 + '\n' + arg2);
}I'm guessing this has something to do with onChange in the first example overwriting the onChange event as defined in the source js (as that onChange returns only this.value), and onChange in the second example just setting a pointer for where this.value should return to. There's got to be some way to get the third example to work, though; I've thought up a complex method of adding a hidden and having the onChange change the hidden's value, and then adding an onChange event to the hidden allowing me to then do a complex function with args, but that is a back-asswards way to achieve what I want to do. In simple terms, I want the onChange of my InlineEditBox to do something like onChange="myFunction(value,id,somearg,anotherarg)" where everything but value is known at the time of creating the editbox, and this.value could be accessed like it is in the first example. Anybody have some advice or know how to achieve this behaviour? Greatly appreciate any help, thanks!

bump
anybody have any ideas here? it's driving me crazy...
why?
This is driving me crazy too. Why would dijit return less information (only this.value) than the DOM onclick event? I wanted a single function that could handle multiple controls, using name, value and displayedValue. Is there no way to simply pass back 'this'?
no idea why but worked around it
if you look a few comments down i figured out how to access "this" from the onclick function - http://dojotoolkit.org/forum/dijit-dijit-0-9/dijit-support/dijit-inlinee...
cheers
You may be able to, after
You may be able to, after you have instantiated the widget, replace the onChange method, e.g.,
inlineEdit.onChange = function(newVal, knownArg1, knownArg2, knownArg3) { ... ... };Then, you should be able to use the programmatic method, with just the function reference, but four values would be passed to your referenced function, three of them known at creation of the widget, the first not known but supplied by the widget.
fixed!
@frankf, I was trying something like that, but ended up getting it working by adding new elements to the inlineEdit object and making onChange an anonymous function,
eg
var inlineEdit = new dijit.InlineEditBox({ autoSave:true, renderAsHtml:false, onChange: function (value){ alert(value); // new value alert(this.table_name); // or this.whatever - lets me set variables that onChange can access }, iditable_enabled_id: someVar, iditable_enabled_column: anotherVar, table_name: oneMoreVar, ... }, dojo.byId(myJSONObject[cnt].iditable_enabled_blocks[iecnt].iditable_enabled_id));thanks for the suggestion though
Yep, that is equivalent, I
Yep, that is equivalent, I believe--both techniques replacing the onChange method.