event-handling

Is there a way track the focus on tab with Javascript?

爱⌒轻易说出口 提交于 2019-12-18 00:29:30
问题 We need to track the EFFECTIVE time on site of our users Most users, when they're done, leave the tab open and move to another tab Time on site it's extremely inaccurate Is there a Javascript Event to track the "loss of focus" of the current tab ? 回答1: This should work both on tab switch and on browser window losing focus: function onBlur() { document.body.className = 'blurred'; }; function onFocus(){ document.body.className = 'focused'; }; if (/*@cc_on!@*/false) { // check for Internet

window.resize due to virtual keyboard causes issues with jquery mobile

吃可爱长大的小学妹 提交于 2019-12-17 23:20:01
问题 I'm hitting an unusual problem and I'm looking for suggestions. Basically, I'm using: JQuery Mobile 1.1 JQuery 8.2 PhoneGap (Cordova) 2.1 On many pages in my app on iPhone, if I put my cursor into an input box, this opens the virtual keyboard. That's fine and expected. Here's the problem: In some cases (but not all), placing my cursor into an input box fires the window.resize event. I've verified this via the code below: $(window).resize(function(e) { alert('The window resize occurred! Width:

Execute backing bean action on load?

时光怂恿深爱的人放手 提交于 2019-12-17 23:15:03
问题 I would like to build a results page for a report export page. This results page must display the status of the export and offer the download of this export. The export is done in an action method. I can execute it via a commandButton but it must be executed automatically on load. How can I accomplish this? JSF: <h:commandButton value="Download report" action="#{resultsView.downloadReport}"/> Backing bean: public String downloadReport() { ... FileDownloadUtil.downloadContent(tmpReport, REPORT

ASP.NET/HTML: HTML button's onClick property inside ASP.NET (.cs)

点点圈 提交于 2019-12-17 23:12:27
问题 I just wanna find out if there's a way to put my onClick event inside .cs: <button type="submit" runat="server" id="btnLogin" class="button" onclick="btnLogin_Click();"> where Login_Click() should be inside .cs: protected void btnLogin_Click(object sender, EventArgs e) { // do something } Please do take note that I will not use ASP.NET button here, and that I will not put my Login_Click() event inside .html/.aspx so I can't 'expose' my codes. Any suggestions? 回答1: You can do that on any

Javascript event delegation, handling parents of clicked elements?

自古美人都是妖i 提交于 2019-12-17 22:52:03
问题 http://jsfiddle.net/walkerneo/QqkkA/ I've seen many questions here either asking about or being answered with event delegation in javascript, but I've yet to see, however, how to use event delegation for elements that aren't going to be the targets of the click event. For example: HTML: <ul> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> <li><div class="d"></div></li> </ul>​ CSS: ul{

How to overwrite jquery event handlers

孤街醉人 提交于 2019-12-17 21:57:24
问题 I'll try to explain the problem with a simple code. var fireClick = function() { alert('Wuala!!!') }; $('#clickme').click(fireclick); $('#clickme').click(fireclick); So now it will obviously alert 2 times but i need it alert only once. Tried so many ways, but no result. Thanks. 回答1: As of jQuery 1.7 you should be using off to remove event handlers and on to add them, though you can still use the click shorthand. $('#clickme').off('click').on('click', fireclick); $('#clickme').off().on('click'

Allow just one click in class JQUERY

喜你入骨 提交于 2019-12-17 21:16:43
问题 I have a link that will load via ajax some content. My problem is, I don't want to remove the text "Load comments", I just want to not allow more clicks in this class. <a href="javascript:;" class="showcomments" id="'.$idf.'">Load comments</a> Jquery var Progressajax = false; $(function() { $(".showcomments").click(function(){ if(Progressajax) return; Progressajax = true; var element = $(this); var id = element.attr("id"); Progressajax = false; alert("ok"); $(data).hide().prependTo('.varload'

call a function in a component from another component

℡╲_俬逩灬. 提交于 2019-12-17 20:54:30
问题 In Angular2 , assume I have component1(use it as left panel navigator) and component2 .these two components are not related to each other (sibling, parent and child, ...). how can I call a function in component1 from component2? I cant use event binding here. 回答1: Shared service is a common way of communication between non-related components. Your components need to use a single instance of the service, so make sure it's provided at the root level. Shared service: @Injectable() export class

jQuery - convert .live() to .on()

故事扮演 提交于 2019-12-17 20:36:19
问题 How do I go about combining this old jQuery code into the v1.7 .on() ? v1.3 .live() : $('#results tbody tr').live({ mouseenter: function () { $(this).find('.popup').show(); }, mouseleave: function () { $(this).find('.popup').hide(); } }); v1.7 .on() : $('#results tbody').on('mouseenter', 'tr', function () { $(this).find('.popup').show(); }); $('#results tbody').on('mouseleave', 'tr', function () { $(this).find('.popup').hide(); }); I want to pass both event handlers to one .on() call, but

Handling click events on z-index'd layers

时光毁灭记忆、已成空白 提交于 2019-12-17 20:09:16
问题 I have 2 z-index layers in a map application I'm building. I have a problem when I click on the layers to zoom in. The click handler is on the underlying z-index layer and I don't want it to fire when a control in the overlying layer is clicked. The problem i have is that the event gets raised no matter what but the originalTarget property of the event is not the image in the underlying layer when something on the top layer is clicked. Is there anyway to change this? 回答1: It's called event