event-handling

Jasmine can't spy on event handler?

烂漫一生 提交于 2020-01-01 04:37:10
问题 Trying to test that an event handler gets called on a clicked element with Jasmine. Have a "Pad" object that contains a DOM element "PadElement", which gets clicked. The event handler is a method on the Pad object: GRAPH.Pad = function(graphDiv, graph) { this.graph = graph; this.clickHandler = function(e) { console.log('padElement clickHandler called'); //this.graph.createVertex(e.clientX, e.clientY); }; this.padElement = GRAPH.padElement(graphDiv, this.clickHandler); } GRAPH.padElement =

How to detect if an element has scrolled out, but only once?

China☆狼群 提交于 2020-01-01 03:37:34
问题 I am trying to detect if an element has been scrolled out and have done the following code $(window).bind('scroll', function(){ var $btn = $('#intro div.summary a[href=#top]'); if($(window).scrollTop() > ($btn.offset().top+$btn.height())){ console.log('out'); } }); I have an anchor in some body text, that I am hoping to clone and make a fixed nav out of once the div.intro is scrolled out. My problem is that the code fires as soon as the element is out of view, but keeps firing. So I cannot do

Flash AS3 EventDispatcher - any way of getting a list of registered listeners?

旧巷老猫 提交于 2020-01-01 02:42:25
问题 Is there any way of getting a list of registered listeners for an EventDispatcher ? I know that EventDispatcher has the hasEventListener method to tell you if any listeners are registered, but is there an easy way of interrogating the EventDispatcher to find out what the listeners are? One way I figured to do this was to subclass EventDispatcher to override the addEventListener method and store the listeners in a dictionary, but this feels clunky to me. Any ideas? 回答1: Ok, so it seems that

Is there a way to use event.preventDefault with focusOut? If not, why?

☆樱花仙子☆ 提交于 2020-01-01 01:40:12
问题 I would like to prevent the default event from a focusOut (or blur ) event and keep the focus set to the specific input field. This is what I have already tried: using event.preventDefault() at the beginning and at the end of the function (for test purposes, not for style) return false; to prevent propagation setting the focus back to the element directly in the element (but I found that the focus still switches because the focus switch is executed after the .on() function executes. I know I

the getSource() and getActionCommand()

不打扰是莪最后的温柔 提交于 2019-12-31 10:48:35
问题 What is getSource? and what does it return? and what is getActionCommand() and what does it return?? I am getting confused between these two can anyone give or differentiate them to me? what's the use of getSource and getActionCommand() in UI's? specifically TextField or JTextField? 回答1: Assuming you are talking about the ActionEvent class, then there is a big difference between the two methods. getActionCommand() gives you a String representing the action command. The value is component

the getSource() and getActionCommand()

随声附和 提交于 2019-12-31 10:48:12
问题 What is getSource? and what does it return? and what is getActionCommand() and what does it return?? I am getting confused between these two can anyone give or differentiate them to me? what's the use of getSource and getActionCommand() in UI's? specifically TextField or JTextField? 回答1: Assuming you are talking about the ActionEvent class, then there is a big difference between the two methods. getActionCommand() gives you a String representing the action command. The value is component

Retrieve contents of HtmlGenericControl inside ASCX WebControl

女生的网名这么多〃 提交于 2019-12-31 07:22:47
问题 I have an HtmlGenericControl which is a simple DIV with runat=server This Control is embedded inside of an ASCX WebControl which resides on multiple pages. At Page_Load this element is populated by a repeater that is data-bound to database data that is Page Specific. The trouble I'm having is ASCX WebControls don't seem to read the contents of their own elements very easily. So far this has failed: How do I get the HTML output of a UserControl in .NET (C#)? I'm looking for a way to get the

Retrieve contents of HtmlGenericControl inside ASCX WebControl

社会主义新天地 提交于 2019-12-31 07:21:07
问题 I have an HtmlGenericControl which is a simple DIV with runat=server This Control is embedded inside of an ASCX WebControl which resides on multiple pages. At Page_Load this element is populated by a repeater that is data-bound to database data that is Page Specific. The trouble I'm having is ASCX WebControls don't seem to read the contents of their own elements very easily. So far this has failed: How do I get the HTML output of a UserControl in .NET (C#)? I'm looking for a way to get the

Forwarding Events of Different Type

别来无恙 提交于 2019-12-31 07:01:19
问题 I'm trying to forward events from one class to objects contained within it (as described here: Forwarding events in C#). However, the events are of different type. For example, I have a class Item which exposes a ValueChanged event handler of type EventHandler . The class ItemHaver exposes an EventHandler<StatusEventArgs> , which should fire whenever Item.ValueChanged does, but should also provide additional information. How do I properly implement add/remove to the ItemValueChanged event

How to add an onclick event on a newly added row (DataTables)?

人走茶凉 提交于 2019-12-31 05:40:36
问题 I'm adding rows dynamically using table.row.add and I want to, for every row that is added to the table, to also add an onclick event to that row so it links to a URL. So, how do I refer to the row that has just been added to add this event? 回答1: You can add an onclick to this event : $(document).ready(function() { $('#example').DataTable( { "createdRow": function ( row, data, index ) { // here } } ); } ); 来源: https://stackoverflow.com/questions/51596062/how-to-add-an-onclick-event-on-a-newly