PDA

View Full Version : how to know arg of function



ratno
22 May 2009, 10:28 AM
i'm sorry, still nubie here.

i was trying extcore manual, when come to hover i find difficulties, here the example:


// handles when the mouse enters the element
function enter(e,t){
t.toggleClass('red');
}
// handles when the mouse leaves the element
function leave(e,t){
t.toggleClass('red');
}
// subscribe to the hover
el.hover(over, out);


then i try to create similar but using fly


Ext.fly('test').hover(function(e,t){t.toggleClass('red')}, function(e,t){t.toggleClass('red')});

above code say error that t.toggleClass is not a function, inspecting using console.debug t is dom element, so that's why i cant use the function. Either the manual is wrong or i did something wrong in my code, direct me please?.

secondly, how can i know that the first argument of hover (overFn) can take 2 args or more, i try to find this args in api docs, but cant find it. can anybody explain it to me?, or direct me to read somewhere.

and one thing, when i search action, api docs return ext.action but when i click it, it return 404 html error.

thanks in advance.

Animal
22 May 2009, 10:54 AM
What API docs are you looking at?

ratno
22 May 2009, 11:00 AM
i'm looking at ext core docs which ship with extcore zip file, and i try too with http://www.extjs.com/products/extcore/docs/

mjlecomte
22 May 2009, 1:30 PM
The Ext core manual is relatively new, still has several documentation problems. The bug you found was reported in this thread http://extjs.com/forum/showthread.php?p=313909#post313909.

The Ext API Docs on the hover method look like they could use some elaboration as well. The arguments passed to the handler are currently undocumented.

It looks like the handlers are passed 3 parameters: event, DOM target (not Ext Element), and options specified in hover's 4th argument (listener options and custom properties).

Manual/docs should be corrected to something like:


// handles when the mouse enters the element
function enter(e, t, options){
//t.toggleClass('red');
// t is DOM element, need to convert to Ext.Element
var el = Ext.get(t);
el.toggleClass('red');
}

// handles when the mouse leaves the element
function leave(e, t, options){
//t.toggleClass('red');
var el = Ext.get(t);
el.toggleClass('red');
}

var el = Ext.get('elId2');

var options = {
foo: 'bar',
single: true
};

// subscribe to the hover
//el.hover(enter, leave, el, options);
Ext.fly('elId2').hover(enter, leave, el, options);

ratno
22 May 2009, 8:13 PM
thanks very much MJ, it's a relieve, been trying hard to find my mistake.
i'll be waiting for it to be fix.

ratno

mjlecomte
22 May 2009, 9:19 PM
To clarify, I think it is a documentation bug, so nothing for you to 'wait for'. I don't know that there's a code bug.

ratno
23 May 2009, 12:21 AM
apologize for my poor english, i mean the fix/appending any miss docs in api documentation, coz i feel helpless without it.
i'm not gonna wait as an idle, but while waiting i think i can still struggle to learn this, and i think it'll not as hard as to grasp extjs concept, coz i feel failed to get to understand the whole system in extjs 2, i'll start over again in this ext-core, hopefully in the future help me to understand extjs 3.
i like to read this forum, but sometimes i just cant keep it with my pace, i'll try harder then.
thanks again MJ.

Animal
23 May 2009, 12:35 AM
If you just debugged your code, you would easily find out that the second argument is DOM element, not an Ext.Element

ratno
23 May 2009, 2:56 AM
If you just debugged your code, you would easily find out that the second argument is DOM element, not an Ext.Element



above code say error that t.toggleClass is not a function, inspecting using console.debug t is dom element, so that's why i cant use the function. Either the manual is wrong or i did something wrong in my code, direct me please?.


yups i was doing that, but for nubie like me my assumption was that ext-core, its manual and its api docs is flawless. so i tend to find maybe something wrong with me, if i without repeating trying then come to ask into forum that would be bad isnt it.

but my main question was not that, it was how can i find the arguments for callback function as the title of my question in this case argument for overFn and outFn in hover function. And i was relieve knowing that "the arguments passed to the handler are currently undocumented" as MJ said. I relieved because the fault wasnt mine (coz i try to find it in api doc but found nothing), that's means alot to me as whether i learn this on track or not.

Animal
23 May 2009, 3:05 AM
It just uses the mouseenter and mouseleave events.

ratno
23 May 2009, 4:33 AM
It just uses the mouseenter and mouseleave events.

i see.., in developer.mozilla.org i found only one args that is the event itself.
Any link resource so that i can read further to override those events, i mean to know how many args that i can use for that event, and what are they?,

thanks in advance.

Animal
23 May 2009, 5:22 AM
The target and options config from the addListener call are passed after the event.

I will add this to the event descriptions in the 3.0 Ext.Element API docs.

mjlecomte
23 May 2009, 5:33 AM
As eluded to here:
http://extjs.com/forum/showthread.php?p=333393#post333393

IMHO I suggest you give preference to referencing the full ExtJS API Docs and not the core manual. The ExtJS API Docs are more rigorously maintained than the manual is AFAIK.

Note that the online docs are only update when there is a new release to the library. If you want to get continuous updates of code/docs then you need svn subscription.

ratno
23 May 2009, 7:05 AM
The target and options config from the addListener call are passed after the event.

I will add this to the event descriptions in the 3.0 Ext.Element API docs.
From revised example that MJ posted was clear that it has three args, but from where it comes from was unknown, except the event :D. So this is only work in extjs, nice thanks for the info. In conclusion all event would have this three args event, target, and options.



IMHO I suggest you give preference to referencing the full ExtJS API Docs and not the core manual. The ExtJS API Docs are more rigorously maintained than the manual is AFAIK.

ai ai sir, i'll use extjs api docs from now on :D.

Thanks Animal, MJ.

mjlecomte
23 May 2009, 7:48 AM
In case you are not aware, the full ExtJS is built on top of Ext Core. So ExtJS has everything that Ext Core does. Whatever property you want to look up in Ext Core is exactly the same property in ExtJS (it's the exact same code)...ExtJS just adds to Ext Core. This is why I am saying that you can reference the ExtJS docs for any methods you want to use in Ext Core. Just realize that not everything in ExtJS is in Ext Core.

ratno
23 May 2009, 8:29 AM
In case you are not aware, the full ExtJS is built on top of Ext Core. So ExtJS has everything that Ext Core does. Whatever property you want to look up in Ext Core is exactly the same property in ExtJS (it's the exact same code)...ExtJS just adds to Ext Core. This is why I am saying that you can reference the ExtJS docs for any methods you want to use in Ext Core. Just realize that not everything in ExtJS is in Ext Core.

ok, i'll keep that in mind.