JQuery :: Bind Works But Live Does Not Work For Multiple Events?
Mar 1, 2010Following code works.
$('#container a').bind('click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
[Code].....
Following code works.
$('#container a').bind('click', function(e){
log( $(this).text() + ' clicked1');
return false;
});
[Code].....
I am in the process of porting an application i have been building for a couple of years to jQuery from jquery/prototypejs&scriptaculous.
Reading the new documentation i see that bind can take multiple observers (for example)
$(
"div.test"
)
.bind
(
[Code].....
Is this also true with "live" ( i am adding alot of dynamic elements to a page that have tooltips attached to them and have written a simple tooltip plugin that uses live to stop me constantly needing to call the plugin everytime somehting on the page changes to do with the tooltip..
Im working on a ajax app and not sure what is the best way to bind events to elements (performance wise).I have a number of elements with 'click', 'focus', 'keydown' events which can be assigned though the delegate to the parent, like so:$('#parent').delegate('#child', 'click', func.....)but is it better to add a delegate to the 'document' for multiple events and use IF statement to filter for elements which should fire an event, like so:[code]Each element can be replaced with an updated version retrieved from the server.
View 2 Replies View RelatedI use the live - method to bind a handler to a click-event for all links with class "userDiv"
When I DON'T use this and use instead the "normal" click handler
I can still use the middle Mouse-Button in Firefox to open the link in a new tab without any jquery-stuff
But when I use the live-method (and it would be nice to use it) the middle Mouse-Button behaves like the left one.
This is my Html: I am trying to get the element that I binded to live(), but always i am getting it's children. For example, this is my code:
<div id=div1 class=theClass><b>Hye</b></div>
<div id=div2 class=theClass>Hello
</div>
[Code].....
I have this odd situation in which a function receives an element that needs some cleanup; all events to which it is bind to should be removed
Unfortunately, I don't know if the events are bind using 'bind' or 'live'
Is it possible to use find this out somehow using only this element ?
It looks like when I do $("object").bind("<mouse-event>") the event isn't actually being bound to the element in Chrome and Firefox (not sure about IE). Using $("object").each(function()
[Code]...
I haven't seen much mention of this on the web, and only recently discovered it works.... not sure if this is somehow bad practice or just a lesser known trick, but lately I've been chaining .ready() at the end of .html() when I want to bind events to new ajax data. I presume it's much more efficient than live(), and avoids racing issues. E.G.:
$.ajax({
type: 'POST',
url: 'myPage.html',
success: function(c){
$(".response").html(c).ready(function() {
bindNewEvent(".response a");
});
});
function bindNewEvent(o) {
$(o).click(funciton() { ...etc... });
};
There's infinite docs about using .ready() to process the document, but not returning HTML. Passing the above along should anyone find it useful or have insight onto why it's seemingly not mentioned elsewhere.
I normally do this with livequery:
So any new .mylink's on a page would also be bound with my custom function.
How can I do this with the new LIVE event? or is it even possible?
i'm loading a simple svg file with the embed html tag:<embed height
='280
' id
='map
[code]....
Internet Explorer can't bind events to absolute positioned elements ? can't bind a "click" to an element that is overlapping another.Have tried loads of different ways, here are 5 of them:
version 1:
$(".classHolder").click(function(){ alert( $(this).html() ); });
version 2:
[code]....
I am finding that remove() does not remove live events. I'm wondering why this is. I've also noticed that the selector for .die() has to be specificand I can not simply do $("*").die().Is there a reason for this? I found that if I use delegate instead of live then it does get detached. I'd like to understand this since it's causing double/triple event triggering in my pages.
View 2 Replies View RelatedI am trying to accomplish something like this:
<p>
text <a>link</a>
</p>
----
$("p").live("click", ... something cool...);
$("p a").live("click", function(e){e.stopPropagation();});
//so the link is still followed but the click event on the P is not triggered.
This fails since live events bubble differently than bound events. So, what I have to do instead is $("p a").live("click", function(e){return false;}); but then the link is not followed. So, I do $("p a").live("click", function(e) location.href=this.href; return false;}); but then "open in new window" doesn't function correctly. Is there a good way to overcome this limitation/behavior?
I've come across an issue where I've got a dynamically created popup class that despite appearing to be bound according to Visual Event does not fire on clicking the closebutton attached to it. I'm not getting any errors in firebug and by setting breakpoints I've verified we are not reaching the code to execute. Ruling out the usual suspects such as obvious spelling mistakes/ swapping out jquery versions 1.3/1.4/1.5 doesn't make any difference.where else I can look?Here is the original function:
$this.find(".close").live('click', function() {
var $this = $(this);
$this.parents("." + sets.popupClass).remove();
[code]....
I am looking for a way to simulate the actions of the hover (or mouseenter/mouseleave) whilst using the live method of binding (The items are dynamic). Is there a way to do this or will I need to use the 'old fashioned' method of unbinding and rebinding? I do not want to use a plugin.
View 6 Replies View RelatedI have a problem with this script: $('#clickshow1').mouseover(function() {
[Code]...
I have 2 or more objects that onclick(), will call the same function. Right now I have the following:
....
$("#obj1").change( function() {
setupPage();
});
$("#obj2").change( function() {
[Code].....
I was wondering if there is a way to simplify or clean up the code, since they are all doing the same thing and responding to the same event. This is just for refactoring reasons because my code is getting too long/messy.
Liferay 4.4.2 + jQuery 1.7.1Lib loads correctly (I use noConflict method because in Liferay there is 1.1.4 jQuery). I check for example $('someDiv').hide() and this works correctly.
But .bind() method doesn't work.
Windows Media Player, Adobe Reader, etc.
None of these can have events interacted with via jQuery's bind(), although falling back to the native implementations work fine.
I have this in my jQuery() function:
$( "#admin_new_records ul a" ).live( "tap", function() {
jQT.goTo( "#admin_new_records" );
return false;
});
I create the links that match this on the fly with jquery.builder.js, and have confirmed that searching the resultant DOM in the console with the string "#admin_new_records ul a" does indeed return the elements I want. The problem is that when I click on the links, the jqt framework still seems to handle the tap, and returns to the first screen with an error due to the fact that it cannot recognise the url I created for the links. The issue seems to be that live does not work, but I have also tried to set this on tap() immediately after creating and appending the links, and this does not work, either.
I'm having with a sortable table script.
var sortableTable = new Class({:thumbsup:
getOptions: function(){
return {[code]....
It works flawlessly on my dev page: http:[url].....But I am having issues with is on my live page: http:[url].....My first thought is that it could be a labeling issue (ie: I forgot to remove "/dev" when moving the HTML over to live) but after reviewing for an hour, I don't believe this is the issue.
I've got an external server with an application that retrieves some information to display on a page if available. Data should be returned as a JSon object. I've got this to work locally for all browsers but for some reason when I put it onto a live website it will not work for certain browsers...
Here the code...
Code:
var servletaddress = 'http://www.applicationaddress.com/DataR/';
function getJson (type) {
var httpRequest = getHttpRequest();
[Code]....
If I deploy a *.html file into a locally running Tomcat fro example, the web page requests the data from the external server on [URL] for all browsers I've tested.
If I put this section of code up onto a live environment e.g [URL] the JavaScript will no longer work in all browsers eg IE6 yet still works in Chrome & Firefox...
Normally this would be security settings or something on the browsers I guess but its the same browser window locally as externally.
I have a problem when I use the .live() function that I can't figure out. It's something I've run across several times and it keeps confusing me.
My jQuery:
jQuery('#content div.portfolio').live({
mouseover: function(){
jQuery(this).find('img').fadeOut();
[code]....
My problem is: when the mouse enters and leaves the image the image fades in and out for up to four times. The first mouseenter is just fadeout, fadein, fadeout. why is the event being triggered multiple times and more importantly what can I do to prevent this behavior?
I have an error and I don't know how to solve it. Well I load a page into a div called 'entry_container'for my WP theme and I use this function:
[Code]...
I found the bug ticket with similar problem: [URL] but it was closed as invalid. The problem still exists for me. I have the following live event: $("a:not([onclick])").live('click', ajaxLinkHandler); It's not applying to content loaded via $.ajax(...).responseXML which I used to append in the following way:
// withing ajaxLinkHandler
var content = $(loadedDocument).find("[component='"+ id +"']");
$(this.contentContainer).empty().append(content);
I am trying to work live method work but could not if id/name has . (dot) character.jQuery1.4.2Example:
<html>
<head>
<script type="text/javascript" src="../scripts/jquery-1.4.2.js"></script>
[code]....