I have two custom controls tDescendant1 and tDescendant2 that are descendants of other custom control tAncestor. tAncestor handle some events as MouseDown, Click, etc. tDescendant1 and tDescendant2 also must handle the Click event, so they, in turn, set the ancestor's OnClick event to its own handler.
I have on the form Descendant1 and Descendant2 (wich are instances of tDescendant1 and tDescendant2 respectively) and I need that when an OnClick event is fired on Descendant1, the underlying tAncestor of Descendant2 be notified.
Can I use observers to accomplish this?
Appreciate any suggestion. Thanks.
Related
According to the XForms specification most events are said to "bubble".
As per the DOM Level 2 Event Specification an event that "bubbles" means that the handlers for this event associated with ancestor elements of the event dispatch target will also receive this event.
For an event to be specified as "bubbles" it means the xf:dispatch action cannot modify the bubble behavior to limit it to the target.
I don't understand what the benefit is of so many xforms events to bubble. For example, xforms-select and xforms-deselect. They apply to xf:item (of xf:select*) and xf:case (of xf:switch, i.e., used in a form with tabs).
Let's say I have an xf:case with an xforms-select handler that will cause a refresh on an expensive rendering widget, just when the tab is actually selected rather than every time the model is updated. Now I also have an xf:select in that same tab. Now whenever the user selects another item in that selection, the xf:case would receive the xforms-select at the bubble phase, doing the costly update operation every time.
This doesn't seem to make sense.
In fact xforms-node-attached has it right: we really want to be specific as to which form element gets the node attached. But apart from that, most events are said to bubble.
I could conform myself better with this issue if I understood the reason for this. Otherwise I am tempted to change my XForms engine to change the definition of xforms-select and xforms-deselect not to bubble.
This is to allow what is known as event delegation:
"Event delegation refers to the process of using event propagation (bubbling) to handle events at a higher level in the DOM than the element on which the event originated. It allows us to attach a single event listener for elements that exist now or in the future." (from an older version of this jQuery doc page)
In general, this is a good thing:
You use less event listeners.
A listener can listen on multiple targets.
You don't need to remove/add listeners as DOM elements are added/removed.
It seems that, in the HTML world, things have moved towards letting everything bubble. For example, the old focus event didn't bubble, and the newer focusin event bubbles.
If you have an event handler which gets activated by events dispatched to multiple targets, in some cases you need the ability to discriminate. This is where event context information is useful. Libraries like jQuery also allow you to associate an event handler filtered by CSS selector, which is neat.
Now in the case of xforms-select specifically, your issue is that you cannot discriminate between this event dispatched to an xf:case vs. an xf:select. This might mean XForms shouldn't have a single event for these two scenarios, or it should have enough event context information to discriminate between the two. I don't think that this is making a case for not letting the event bubble.
I have read all the official documentation of jQuery 1.7.2, but I cannot find any detail about the 'beforechange' event (or something like that) which help me control some rules before allowing the element to change its value. Is there any plugins provide this handler?
Thank you so much!
The jQuery api doesnot provide the 'beforechange' event but instead provide great flexibility to write our own custom events. We can define our own custom events and can be triggered when the events is fired.
For example for input elements we can have onkeydown or onkeypress events and when fired we can trigger our custom events to control some rules.
The following link provides information for creating custom events. Its very simple and flexible.
http://scriptble.com/2009/05/custom-events-with-jquery
I don't understand if anything is wrong in this idea but the Backbone Views just don't trigger keypress, keyup events. I have created a simple shopping list app is JsBin for you to inspect. In the chrome inspector the ul of the view shows the keyup event but it does not occur when i hit some keys in the keyboard. I need the idea to navigate Treeview using the keyboard events
Jsbin
http://jsbin.com/arucom/2/edit
In addition to the question #rkw linked You might want to have a look at this SO question Why audio events are not firing with BackboneJS but others are?
Basically backbone.js uses delegation to bind events, which only works with delegate-able events.
You can bind to the keypress manually in the initializer
initialize: function () {
_.bindAll(this);
$(document).bind('keyup', this.navigate);
},
I am trying to find a list of all the possible values I can pass to the attribute event of the f:ajax tag.
I know that I can also pass function names from my .js files, but what I need just the ones that come with JSF.
I only know about click mouseover and keyup, but I am sure there are more. Just don't know where to find them.
The event attribute of <f:ajax> can hold at least all supported DOM events of the HTML element which is been generated by the Faces component in question. An easy way to find them all out is to check all on* attribues of the Faces input component of interest in the Faces tag library documentation and then remove the "on" prefix. For example, the <h:inputText> component which renders <input type="text"> lists the following on* attributes (of which I've already removed the "on" prefix so that it ultimately becomes the DOM event type name):
blur
change
click
dblclick
focus
keydown
keypress
keyup
mousedown
mousemove
mouseout
mouseover
mouseup
select
Additionally, Faces has two more special event names for EditableValueHolder and ActionSource components, the real HTML DOM event being rendered depends on the component type:
valueChange (will render as change on text/select inputs and as click on radio/checkbox inputs)
action (will render as click on command links/buttons)
The above two are the default events for the components in question.
Some Faces component libraries have additional customized event names which are generally more specialized kinds of valueChange or action events, such as PrimeFaces <p:ajax> which supports among others tabChange, itemSelect, itemUnselect, dateSelect, page, sort, filter, close, etc depending on the parent <p:xxx> component. You can find them all in the "Ajax Behavior Events" subsection of each component's chapter in PrimeFaces User's Guide.
I just input some value that I knew was invalid and here is the output:
'whatToInput' is not a supported event for HtmlPanelGrid.
Please specify one of these supported event names: click, dblclick,
keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover,
mouseup.
So values you can pass to event are
click
dblclick
keydown
mousedown
mousemove
mouseover
mouseup
I have a aspx page that contain "asp:RequiredFieldValidator" controls;Problem that is when each of "asp:RequiredFieldValidator" controls activate and show their messages; other controls in my page don't working even "CANCEL" button!!!
i want to enable controls in my "NEXT" button MouseDown and then disable them at my "NEXT" button MouseUp.
Thanks for any other solutions...
Specifically to answer your question as stated in your title: to add additional event handlers to an asp:button or other server controls that are not composite you simply add the handler to the element. Include onmousedown="myMouseDownHandler(this);" in the element and the javascript function myMouseDownHandler will fire.
However, I think there is a better way to do what your asking but the description of the question is not coherent enough for me to quite figure out what you're asking. I realize you may not be a native English speaker but perhaps you could give it another pass.
Use ValidationGroup property on controls that are validated and controls that triggers validation (e.g. save/update buttons) and on validators. Additionally set CausesValidation property to false on each button that does not need to trigger validation (cancel button).