Does keypress events not apply to Backbone.js Views - events

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);
},

Related

FireMonkey observers

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.

prevent beforeSelectRow event, when a user doubleClick any Row in jqgrid

I am using cell editing in jqgrid and for that, i am using many different jqgrid events, as mentioned below ...
1) beforeSelectRow, 2)beforeEditCell, 3)afterEditCell, 4)onCellSelect, 5)ondblClickRow, etc...
Now, when i doubleClick on any of the row, the beforeselectRow code gets executed first.. which i want to prevent... but how to do that ??
Some example code is as below :-
ondblClickRow: function(id,irow,icol,e)
{
........
},
beforeSelectRow : function(rowid, e)
{
if(rowid==lastSelected)
{
$sampleDialog.dialog('open');
}
}
Different web browsers process the double-click event in a little different ways. So in general you can't prevent 'click' event before 'dblclick'. The callback beforeSelectRow will be called inside of click enevt handler defined inside of jqGrid code. In jQuery documentation of dblclick event handler you can read the following (see here):
It is inadvisable to bind handlers to both the click and dblclick
events for the same element. The sequence of events triggered varies
from browser to browser, with some receiving two click events before
the dblclick and others only one. Double-click sensitivity (maximum
time between clicks that is detected as a double click) can vary by
operating system and browser, and is often user-configurable.
What you currently do is just not recommended way to binding both 'click' and 'dblclick' handles.
You don't describe the original problem which you has which is probably somewhere inside of ondblClickRow callback implementation. The only solution will be to examine reorganization of the program to have no collisions between the actions inside of beforeSelectRow and ondblClickRow callbacks.

Jqgrid Edit Form Change Event of Select doesnt fire when scrolling thorugh records

I have been following this example, http://www.ok-soft-gmbh.com/jqGrid/DependendSelects2.htm, as it is just what I need. I have got it working but it doesnt work when scrolling through records. If you bring up the form and scroll from a UK record to a US record, the list doesnt change. The onChange event only fires when the user selects from the select drop down.
Is there a way around this?
Thanks for your help.
James
My old demo uses 'change' event handler defined in the dataEvents property of the editoptions. In the dataEvents array one can define other event handlers.
You need just bind keyup to the column exactly like it's described in the answer. In the body of the event handler you can do the same actions as in the body of the 'change' event handler (you can place the code in a function and call it from the both handlers). In the way you should be able to solve the problem.
UPDATED: I updated the old answer and another one which was origin for the demo which you used. The new demo support the navigation buttons (the buttons to edit the 'next' or the 'previous' row) in the editing form.

Jquery window scroll / resize works on bind, not on live

So I have an advanced search form, and when you scroll down the results, the search results summary sticks to the top of the page as you scroll using the 'sometimes fixed' code described here - http://www.bennadel.com/blog/1810-Creating-A-Sometimes-Fixed-Position-Element-With-jQuery.htm
This all works very nicely, but when some of the form elements are changed, it reloads the whole form, results summary, and results list using AJAX.
I noticed it was using bind to check for the scroll / resize, but the element it needs to effect has obviously been replaced with AJAX, so I changed it to live. This didnt work, on further digging I found out that initially live() only supported certain events, and then was made to work on all events, including custom ones, so why does it still not seem to be working with scroll?
In jQuery 1.3.x only the following JavaScript events (in addition to
custom events) could be bound with .live(): click, dblclick, keydown,
keypress, keyup, mousedown, mousemove, mouseout, mouseover, and
mouseup. As of jQuery 1.4 the .live() method supports custom events as
well as all JavaScript events that bubble. As of jQuery 1.4.1 even
focus and blur work with live (mapping to the more appropriate,
bubbling, events focusin and focusout). As of jQuery 1.4.1 the hover
event can be specified (mapping to mouseenter and mouseleave, which,
in turn, are mapped to mouseover and mouseout).
Have tried it with jQuery 1.4.1, 1.5.1, 1.6.2 and no joy. Am I doing something stupid, or is what I am trying to do just not possible?
Wasnt looking likely I would get an easy solution...
So I rewrote the way the search script worked so that the 'sometimes fixed' div wasnt regenerated by ajax, and it loaded the form, results summary, and results directly into their divs

How can i add a MouseDown event handler to a <asp: button> control?

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).

Resources