jquery-events

How to stop default link click behavior with jQuery

两盒软妹~` 提交于 2019-12-17 04:00:46
问题 I have a link on a web page. When a user clicks it, a widget on the page should update. However, I am doing something, because the default functionality (navigating to a different page) occurs before the event fires. This is what the link looks like: <a href="store/cart/" class="update-cart">Update Cart</a> This is what the jQuery looks like: $('.update-cart').click(function(e) { e.stopPropagation(); updateCartWidget(); }); What is the problem? 回答1: e.preventDefault(); from https://developer

jQuery scroll() detect when user stops scrolling

我与影子孤独终老i 提交于 2019-12-16 19:44:11
问题 Ok with this.. $(window).scroll(function() { $('.slides_layover').removeClass('showing_layover'); $('#slides_effect').show(); }); I can tell when someone is scrolling from what I understand. So with that I am trying to figure out how to catch when someone has stopped. From the above example you can see I am removing a class from a set of elements while the scrolling is occurring. However, I want to put that class back on when the user stops scrolling. The reason for this is I am intent on

jQuery scroll() detect when user stops scrolling

隐身守侯 提交于 2019-12-16 19:41:07
问题 Ok with this.. $(window).scroll(function() { $('.slides_layover').removeClass('showing_layover'); $('#slides_effect').show(); }); I can tell when someone is scrolling from what I understand. So with that I am trying to figure out how to catch when someone has stopped. From the above example you can see I am removing a class from a set of elements while the scrolling is occurring. However, I want to put that class back on when the user stops scrolling. The reason for this is I am intent on

jQuery trigger not firing with bind() or on() for custom events

你说的曾经没有我的故事 提交于 2019-12-14 00:18:09
问题 Can anyone tell me why this code would not be working? $('body').on('test', function() { alert('test'); }); $('body').trigger('test'); I'm using jquery-1.7.2.min . I do not get any errors, just nothing happens. I've tried putting the code inside an inline script, inside a $(document).ready() and still nothing. I've also tried both on() and bind() and neither result. I see examples all over showing the same syntax, so what is different with this? 回答1: It appears the issue lies in the DOM being

Angular 2.0 (Beta, ES5) UI not updating via custom event

狂风中的少年 提交于 2019-12-13 19:48:39
问题 I am having an issues with Angular 2.0.0-beta.2 I have two components loaded separately into a page and communicate is performed between the Angular 2 components and the 'container' website, these events are performed via jQuery's .trigger() and .on(). The idea of this is these components can be integrated into an external website and a predefined set of events can be used to interact between one another. The issue I am having with angular2 however is that the binding is not updating the UI

How to bind to jquery-mobile pagebeforeload event?

放肆的年华 提交于 2019-12-13 01:19:57
问题 I'm getting desperate trying to get the jQuery mobile pagebeforeload event to fire. This just does nothing: $(document).on("pagebeforeload", function( e, data ) { console.log("hello"); }); According to the JQM docs, the syntax is correct. Still, nothing happens. Can anybody tell me why that is? 回答1: Make sure you're including preventDefault(); Otherwise, it'll just merrily continue loading. Docs: http://jquerymobile.com/demos/1.1.0/docs/api/events.html $( document ).bind( "pagebeforeload",

Google Analytics Event Tracking via a jQuery plugin

梦想与她 提交于 2019-12-12 21:31:58
问题 The proof of concept started with this: <script type="text/javascript"> $(document).ready(function() { $('.evnttrk1').click(function() { _gaq.push(['_trackEvent', 'coming_soon', 'footer_icons', $(this).attr('id')]); }); }); With this, any link with a class of eventrk1 would trigger a Google Analytics Event. This worked just fine. From there I decide to roll it into a proper plugin, adding some functionality along the way. Everything about the plugin works except I can't get the _gaq.push to

Can I display/create jsTree on button click?

笑着哭i 提交于 2019-12-12 11:21:39
问题 I have a div id="result" that I use to display results of users actions. I put there plain text and html too. After each user action this div is overwritten with new results . Now I want to display inside this div an instance of jsTree I have working jsTree that loads nicely on page load but it doesn't load after <div id="tree"></div> is inserted inside my result div. I tried two lines below but none worked. $("#tree").jstree("loaded"); $("#tree").jstree("refresh"); Any idea how to make the

swipeleft/swiperight triggered during vertical scroll in jQuery mobile

强颜欢笑 提交于 2019-12-12 08:03:05
问题 Problem is that swipeleft/swiperight event is trigger when I want vertical scroll. We are using jQuery mobile 1.1.0 version and jQuery 1.7.1. and code is: $(document).delegate('#quizResumePage', 'swipeleft swiperight', function (event) { event.stopImmediatePropagation(); if (event.type == 'swipeleft') { $('#btnnext').trigger('click'); } else if (event.type == 'swiperight') { $('#btnprevious').trigger('click'); } event.preventDefault(); }); Then why swipe event trigger when I want to scroll

jQuery target LinkedIn share button

杀马特。学长 韩版系。学妹 提交于 2019-12-12 06:05:22
问题 I have a LinkedIn share button which I need to target with jQuery to save what content was shared etc. I've done the same with Twitter, which has an api for capturing events, but I'm having a problem with LinkedIn. Since it's not an iframe, I figured I can catch events. This is the initial code: <li id="linkedin-share"> <script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US </script> <script type="IN/Share"></script> </li> So, sharing works fine, but I can't capture