Login Register

Help, no event object is passed by dojo.connect

hi.
I build programmaticly a dijit:

var mydijit = new dijit.form.FilteringSelect (props, nodeID);

Then I connect to onChange-Listener

dojo.connect(mydijit,'onChange',function(e) {console.dir(e);});

Console says
object {
0: "10"
endWith: function()
trim: funtion()
}

Anybody an idea whats going wrong?
I never got an real Even-Object passed :(
I never found a solution to track back a fired event function :(

please help, I searched the whole site
greetings,
melchior

FilteringSelect's onChange

FilteringSelect's onChange argument isn't an event, it is the changed value. Look at the API reference:
http://api.dojotoolkit.org/jsdoc/dijit/HEAD/dijit.form.FilteringSelect

dojo.connect only passes along whatever arguments were sent to the function that it's connecting to.

hmmmm

hi bitranch,
thx for your answer

I think I ran into a big trap..
perhaps you can help me, I'm missing the right approach right now :(

My goal was to programmaticly define js-handlers that get hooked similar in doing it by inline dojoType-Method.

I want to get valid Xhtml code by removing all unregular dojoType-inline-Definitions inside tags. So I am trying to build dijits programmaticly by getting the right informations via json (type of dijit, node-id to replace and some custom properties)

In dijit.form.FilteringSelect ie.
I need a js-function called: "updateAll('test',45)" that gets triggered on change
- In doing it 'inline-Method' the [input dojoType='..' onchange='updateAll("test", 45)' was wrapped automaticly to work after render
- In programmatic way I didn't found any solution to hardcode this function into the handler

In dijit.form.Form ie.
I need a "submitForm('myID', this) -function that I used in execute
- In doing it 'inline-Method' the [form dojoType='..' execute='submitForm("myID", this)' was wrapped automaticly to work after render
- In programmatic I failed again

I realized that it seems that I can only pass strict functionnames (without quotes and without parameters) as property to a dijit programmaticly.
If I tried to set up a function name as string to a method (like onChange) where I always get erros (this.onChange is not a function).

For my concept I need a way to define a js-call ie. 'test(1,2,3)' that I can pass from PHP via json to the targeting dijit.

The most important feature I need is to assign my old js-handlerfunctions. Otherwise I'm going to fail (I think)

big thx for comments
melchior

Some really quick testing

Some really quick testing shows that this should work:

var fobj = {};
var fn = dojo.parser._nameAnonFunc(new Function("console.log('it works!')"), fobj);
console.dir(fobj[fn]);
fobj[fn]();

You could, of course, just make do with "new Function('blahBlah(1,2,3)')" but the _nameAnonFunc gives you a unique function name and a place to store the function.

What you're building is

What you're building is really a customized version of dojo.parser. So, I'd look at the source for dojo.parser -- http://archive.dojotoolkit.org/nightly/dojotoolkit/dojo/parser.js -- since dojo.parser already does most of what you're trying to do. (Except dojo.parser does it with DOM nodes and you want to do it with json.) To start, look at the str2obj() function's "function" case and then look for wherever str2obj() is called within dojo.parser.