PDA

View Full Version : [CLOSED] Source and Target - Focus events



macinator
Oct 22, 2013, 6:16 PM
Hi,

I am busy writing a dynamic event handler for all components on my screen

This event handler needs to notify my backend server via a direct event if the user has moved from one field to the next and specifically where the user is and where they intend going
The backend server will them allow the focus change or block it aswell do other things like force updates to the screen etc

So questions:

What is the best way to implement this
a) a blur event linked to every field
b) a verification event

2. regardless is there a way for me to determine the target of a blur event in javascript -
"I need to tell the server at am component 1 and I am trying to go to component 3 - so tell me what what to do"

Sorry for the complex questions, i am writing a dynamic screen scraper that needs to communicate with a legacy environment

Thanks

Mac

geoffrey.mcgill
Oct 22, 2013, 11:03 PM
Maybe take a look at the WordWrench sample in the Examples Explorer.

http://examples2.ext.net/#/Combination_Samples/Applications/Word_Wrench/

A ComponentQuery is hooked up to the <DocumentReady> Listener, which adds an event handler to all Fields that match a certain query. This avoids having to add the Listener to each individual Field/Component.


<ext:ResourceManager runat="server">
<Listeners>
<DocumentReady Handler="
var fields = Ext.ComponentQuery.query('field[autoUpdateData=true], button[autoUpdateData=true]'),
i = 0;

for (; i < fields.length; i += 1) {
fields[i].on('change', function (item) {
App.direct.UpdateData();
}, fields[i], { buffer : 500 });
}" />
</Listeners>
</ext:ResourceManager>

Hope this helps.

Baidaly
Oct 22, 2013, 11:10 PM
Hello!



What is the best way to implement this
a) a blur event linked to every field
b) a verification event


It depends where you create these fields.

If you create them dynamically on client-side then you can get them using ComponentManager's all property http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.ComponentManager-property-all, then you can bind your handler, which I think should be a DirectMethod due to easier implementation in this case.

If you create them on server-side you should be able to bind your handler during creating of controls.

I'm not sure what you mean by verification. Do you mean Remote validation or something else?



2. regardless is there a way for me to determine the target of a blur event in javascript -
"I need to tell the server at am component 1 and I am trying to go to component 3 - so tell me what what to do"


I'm afraid it's not possible but you can listen focus event. Here is some point of that: http://stackoverflow.com/questions/121499