Maybe I am the only one who finds it odd that the .on() function attributes first use the events map, and then the selector, because usually you always have the selector first, then any functions etc... for example $.each(collection, callback)...
I'm trying to make an element dragable on webkit mobile and it works okay the first time you drag, but then when you release and drag again, the element keeps reverting to somewhere near its original position.
I have a carousel functionality and when you click on an element <div id="right"></div> something else slides.
Let's say I'm tracking number of clicks and if you clicked 4 times, I want to disallow further clicking. I of course don't want the event anymore so I am using .off() to remove the event handlers which I store in a global variable arrEvents
arrEvents: {
click: function(){
slideAround(); // a custom sliding function...
}
}
Right now if I remove line 2 below, the second time I click the arrow, the click events I attach on line 3 fire twice. I assume this is because they are already attached from the first click so then jQuery adds two click events in this case.
Is this what's going on? I would have thought adding a second 'click' event to an already existing 'click' event in the .on() function would simply overwrite the first one, not add it.
Doesn't display the "I am working message" until the ajax call is complete.
That doesn't make sense to me, I am appending before initiating the ajax, so what, going on? I thought code is executed top to bottom in javascript, is it not?
In the comments section of the $.ajax() documentation someone points out that you can work around the async false by wrapping the ajax call inside a setTimeout().
$('button').click(function(){
$('body').append('<div>I am working</div>');
setTimeout(function(){
$.ajax({
async:false,
...
});
},0);
});
I did that and it works, but I don't understand why that would be necessary?
does anyone know how to not get "permission denied" in the script when doing a $.getJSON() of a remote JSON feed? (such as the ones you get from google).
thanks for the response below - I made an error in my post and edited it, because my code actually does use getJSON() and not load().
Is this one of those scriopt proxy issues? Does anyone know about these google API feeds?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> $('.item').click(function(){ $('#slider').animate({ // this element is inside another DIV that has CSS overflow:hidden; top: '-200px' },1200); } In FF3, this causes a jaggedy sliding of the elements, very ugly. Looks like the elements are literally jumping up and down while sliding. Not a problem in IE7, though... Has anyone else seen this?
I did this: $('body').append('<iframe name="myFrameName3" src='... etc... now I want to attach a click event to something inside that frame. Does anyone know why the context parameter of the click() below does not work? I can't get the alert to show up. $('#someDiv', top.frames['myFrameName3'].document).click(function(){ alert( $(this).attr('id') ); });
If i want to do something in a parent frame, I would do this: $('#myDiv', top.document).hide(); but what about this following scenario? I'm inside a frame that was created like so: $('body', top.document).append('<iframe id="myiframe"></iframe>'); inside myiframe, I now want to know the id of my iframe, because I would not know it. All I am able to "see" in the DOM is the topmost document. I could traverse through all the iframes and get their ID's but that's useless because I wouldn't know which of them is the one I'm currently in. I suppose I'm simply trying to pass a variable to a child frame so it becomes available on the frame's document.onload().
whats the best way to find the frame name of a click event? in FF I managed to do this: $('#'+e.view.name, top.document) but e.view.name is "undefined" in IE.
I'm using frames (don't ask) and have exhausted my abilities (sniff)... here is some pseudo-code to illustrate the situation: ------------------------ first, CONTAINER.HTM: <script src=jquery.js></script> $(function(){ var module = { something1 : function(var1){ alert(var2); } } }); <iframe src=iframe1.htm></iframe> ------------------------- now, IFRAME1.HTM <script src=jquery.js></script> $(function(){ $('#myDiv').click(function(){ top.frames[0].document.module.something1('hello'); // this line above is the part where I'm stuck. //why won't this darn thing cooperate and alert my variable? }); }); <div id=mydiv>click me</div>
I'm totally not getting it... but you might, I hope :) I appended an iframe: $('body').append('<iframe>...etc</iframe>'); The iframe source has jquery in the header and it works. now I want to do something in that iframe, like hide a div. I want to do this from the top.frame... $('.myDiv', top.frames[0]).hide(); but, it doesn't work!??!? I'm lost. Been googling, all I find is stuff about getting stuff to work in the parent frame - why wouldnt the same work for a child frame? THanks for pointers! much obliged...
I noticed today after much fiddling that .hide() causes the parent element to loose its height(). In other words, height() won't work on elements that have display:none -- causing me to use .hide() only AFTER I've done my .height() - based calculations. I suppose that makes sense but I somehow never really thought that element.height is an attribute that gets set to 0 if display:is set to none...or whatever is actually going on.
this has been discussed before, but I'm still hazy: In FF2 and old Firebug this function ran fine with local files (no local web server, just straight-up file on local desktop). Now Firebug complains "Access to restricted URI denied code: 1012" $.ajax({ type: "POST", url: myFileName, data: {}, dataType: "jsonp", async: false, success: function(ret){ JSON=eval('('+ret+')'); } }); I added the line dataType:"jsonp" after reading up on this inside the list archives. This did nothing. I don't feel like running all my stuff on a local web server just so I can do some simple ajax - am I stuck? Should I downgrade to older Firebug? Any pointers much appreciated!
after searching I found this, which is close but no cigar. http://plugins.jquery.com/node/3997 I appended an iframe to my document, and use livequery: $('.LQelements').livequery(function(){... which works in the top.document, but not in the iframe. How can I re-use this? I don't want to have to copy the function into the body of my iframe source file.
if I have a lot of elements inside <div class"full">...</div> and then do $('.full').empty().append ('blah'); it takes a long time. Is there a way to speed that up?
.toggler {background:#fff;} .open {background:#000;} $('.toggler').click(function(){ $(this).toggleClass('open'); } It's really a CSS problem, because the DOM does toggle the classname. But the background does not change. <div class="toggler open">blah</div> Only solution I can think of is not using toggleClass, but its so nice and simple that way. Anyone know a solution by chance? Thanks a lot!
there are plugins that show a table of results and if you scroll to the enf it fetches more results. I was wondering if someone knows which part is responsible for triggering the load? Is there some jquery ifScrollEndReached() event? I doub t it ;P
Surely this is totally obvious and basic... but I can't seem to figure it out: var myJSONreturnObject = [ {Name: 'hello",Id:11}, {Name: 'hello again",Id:22, SubItem : [ {Thing:"something",Id:234987}, {Thing:"something else",Id:982734}, ] }, {Name: 'hello once more",Id:9}, ] I want to do some sort of query on a JSON object like "SELECT * FROM myJSONreturnObject WHERE myJSONreturnObject.Id = 22" i started with: if(myJSONreturnObject.Id==22) ... and now I'm totally stumped.
hi... would you terribly mind wasting 20 seconds of your day cruising over to http://internalmedia.com/jq/ and letting me know if clicking the drag handle drags the box as expected? Mouse release of course should be stopping the drag. I'm somehow suspicious that my code actually holds up on some of the lesser-used browsers - especially IE6. And if this works on Safari I should be amazed+happy. THANK YOU!