[jQuery] Chaining and each
Kind of large to paste here. My script and resulting HTML can be found at: http://jquery.pastebin.com/m3f98dd99 If you look towards the bottom you will see the following: .parents('td.embedded td.latest') .each(function(i) { $(this) .append(new_table) .addClass('mod' + i); }); I had to add the each because if I didn't my *new_table* was being appended 9 times. With the each it's only appended once, but the class is still added 9 times. Why?
[jQuery] Re: Chaining and each
nevermind. its because parents() runs for each TD (9) On Oct 30, 11:09 am, noon nun...@gmail.com wrote: Kind of large to paste here. My script and resulting HTML can be found at:http://jquery.pastebin.com/m3f98dd99 If you look towards the bottom you will see the following: .parents('td.embedded td.latest') .each(function(i) { $(this) .append(new_table) .addClass('mod' + i); }); I had to add the each because if I didn't my *new_table* was being appended 9 times. With the each it's only appended once, but the class is still added 9 times. Why?
[jQuery] [validate] required that select input's option is anything other than default
I'm trying to throw the field is required option on a select when its selected option is my default option of dashes/0. I might be going about this the complete wrong way with the required (dependency- callback). Help is appreciated. My HTML/JS may make more sense than this quesiton HTML: select name=threshold id=threshold class=required option value=0 selected=selectedmdash;mdash;mdash;mdash;mdash;/option option value=6565#37;/option option value=7070#37;/option option value=7575#37;/option option value=8080#37;/option option value=8585#37;/option option value=9090#37;/option option value=9595#37;/option option value=100100#37;/option /select JS: $('#mount-form').validate({ rules: { threshold { // I don't want to allow the selected option be 0 required: function(element) { return $('#threshold option:selected').val() == '0'; } } } });
[jQuery] $.post and single quotes
I didn't notice until now that my quotes are already being escaped somewhere between after I call $.post() and when my php page picks them up. I have been using mysql_real_escape_string for the way into the DB and strip_slashes for the way out. I don't really want to strip_slashes before I post them to the database, because there could be some slashes intentionally added by the user. But I can't mysql_real_escape_string them with the slash either. Help?
[jQuery] Re: Livequery add class to new DOM elements
livequery accepts two parameters, the first is the event to which a function (the 2nd parameter) is bound to. $('a.someLink').livequery('click', function() { // anchors with a class of 'someLink' // can now be dynamically inserted to the dom // yet still have an 'onclick' event associated with them // as compared to the event only being bound on document ready }); On Jul 16, 2:05 pm, hubbs [EMAIL PROTECTED] wrote: I am trying to get live query to work, so that it will add a new class to links that have just been added to the DOM through ajax. Something is not right though: $('a.calendarNavLink').livequery(function(){ $(this).addClass('ajax'); }); Have I done something wrong here?
[jQuery] Re: Livequery add class to new DOM elements
sorry, I am incorrect. I forgot there were multiple forms. That should work On Jul 16, 2:29 pm, noon [EMAIL PROTECTED] wrote: livequery accepts two parameters, the first is the event to which a function (the 2nd parameter) is bound to. $('a.someLink').livequery('click', function() { // anchors with a class of 'someLink' // can now be dynamically inserted to the dom // yet still have an 'onclick' event associated with them // as compared to the event only being bound on document ready }); On Jul 16, 2:05 pm, hubbs [EMAIL PROTECTED] wrote: I am trying to get live query to work, so that it will add a new class to links that have just been added to the DOM through ajax. Something is not right though: $('a.calendarNavLink').livequery(function(){ $(this).addClass('ajax'); }); Have I done something wrong here?
[jQuery] Re: using live query howto
If your form is dynamically created you can use livequery on that too. I notice you have 'onclick' in yours which is incorrect $('#addLinksForm').livequery('submit', function() { $('#addLinks').livequery('click', function() { // stuff } } On Jul 15, 12:34 am, Tom Shafer [EMAIL PROTECTED] wrote: i am trying to use live query to bind a click to a href on a form submit $(#addLinks).submit(function() { $('#addLinks') .livequery('onclick', function(event) { deleteitem(); }); $.post(addLinks.php,{ step:'addLink',title:$ ('#title').val(),url:$('#url').val(),pageID:$('#pageID').val()} , function(data) { $('#'+$('#pageID').val()). append(li id='link_'+data+a href='javascript://' id='delete' onclick='deleteitem(+data+); return false;'img src='img/delete.gif' //ah1+$('#title').val()+/h1p+$ ('#url').val()+/p/li); $('#link_'+data).effect(pulsate, { times: 3 }, 1000); }); return false; }); im not sure where i should put it, any help would be appreciated thanks -tj
[jQuery] Re: jquery.livequery with with variables
Use an anonymous function wrapper. $('li').livequery('click', function() { deleteitem(id); }); On Jul 15, 4:17 am, Tom Shafer [EMAIL PROTECTED] wrote: i got livequery to bind but i need to be able to pass a variable to it lets say i have a function like deleteitem(id) how can i make livequery use this function with the variable i tried this $(li).livequery(click, deleteitem); but i get a syntax error deleteitem( how would i do something like this thanks
[jQuery] Re: Fading images with jQuery
fadeIn/fadeOut can take a second parameter, a callback. I would assume in your case that the $('app') is hidden and you are fading it in slowly, but you don't wait until that fade in is complete and have it fade out, therefore appearing as its doing nothing at all. $(#app).fadeIn(slow, function() { $('app').fadeOut(slow); }); On Jul 15, 12:31 am, viewsonic712 [EMAIL PROTECTED] wrote: Hi, I would like to fade 4 images with jQuery, 1.jpg, 2.jpg. 3.jpg. and 4.jpg I have the following code, but no luck yet :( script type=text/javascript src=jquery.js/script script type=text/javascript $(document).ready(function(){ for(i=1; i=4; i++) { $(#app).html(img id='yass+i+' src='+i+.jpg') $(#app).fadeIn(slow); $(#app).fadeOut(slow); } }); /script
[jQuery] Re: AJAX bugging out
What exactly is the return from die? Is there an id field in bttt, or are you mistaken and it should be board_id? Every post variable passed is a string unless it is eval'd IIRC. On Jul 14, 3:24 pm, jbhat [EMAIL PROTECTED] wrote: Hi, So i use $.post to call click.php. The variables are getting posted to this function correctly confirmed via firebug id 197 player1 false pos b4 turn bid in my php code, i get them immediately, but when i use $id in mySQL, it seems to disappear: ?php include 'dbconnect.php'; $id = $_POST['id']; $pos = $_POST['pos']; $p1 = $_POST['p1'] == 'true'; if($_POST['turn'] == 'bid'){ $turn = 0; }else if($p1){ $turn = 5; }else{ $turn = 6;} //Malfunctioning Line Below $str = SELECT board_id, p1bid, p2bid, play FROM bttt WHERE id = $id; $query = mysql_query($str) or die($str); $data = mysql_fetch_assoc($query); if($p1){ $str2 = UPDATE bttt_board SET $pos = 'x' WHERE id= . $data['board_id']; }else{ $str2 = UPDATE bttt_board SET $pos = 'o' WHERE id= . $data['board_id']; }mysql_query($str2) or die($str2); $play = $data['play'] . $data['p1bid'] . ',' . $data['p2bid'] . ',' . $pos . ','; $str3 = UPDATE bttt SET turn_state=$turn, play= . ' . $play . ' . WHERE id=$id; mysql_query($str3) or die($str3); ? die is returning SELECT board_id, p1bid, p2bid, play FROM bttt WHERE id = Why is this?? Also, quick question while i have your attention: is $_POST['p1'] the string or boolean 'false'?
[jQuery] Re: jMaps + livequery
Anyone on this? On Jul 14, 10:27 am, noon [EMAIL PROTECTED] wrote: I am using jMaps to add a point to my map and inside the point bubble I have a link to add the searched location to a favorites list. I am using livequery to catch the event handler for this dynamically created point bubble HTML/link. However nothing is firing. I've tripled checked my ID names, and there are no errors when the page has finished loading and the link has been clicked (my event handler isn't firing). Has anyone done something similar with an event listener on an item inside the bubble? Code is here if you're curious -http://pastebin.mozilla.org/487924
[jQuery] jMaps + livequery
I am using jMaps to add a point to my map and inside the point bubble I have a link to add the searched location to a favorites list. I am using livequery to catch the event handler for this dynamically created point bubble HTML/link. However nothing is firing. I've tripled checked my ID names, and there are no errors when the page has finished loading and the link has been clicked (my event handler isn't firing). Has anyone done something similar with an event listener on an item inside the bubble? Code is here if you're curious - http://pastebin.mozilla.org/487924
[jQuery] Re: Calling PHP Functions from jQuery?
No. Suggestion: modify your php page to accept a POST/GET variable specifying the function that you wish to be run... On Jul 14, 10:11 am, Yavuz Bogazci [EMAIL PROTECTED] wrote: Hi, is it possible to call php functions from jquery? I knew how to call a .php page from jquery with $.post and to echo output or return a JSON Object. But my application growth and there is an increase in single php pages. This is very confusing and the filemanagement is getting complicated. How are you solving this problem? Is a good tutorial or info out there? I have searched google and couldnt find a useful answer. thank a lot yavuz
[jQuery] Re: slideDown hidden portion/bump
I wrapped it in a div and slid the div. Still same problem, visible again at http://nunyez.googlepages.com/slidedowntest On Jul 8, 6:37 pm, Karl Swedberg [EMAIL PROTECTED] wrote: Try wrapping the form in a div and sliding that down. That should work. --Karl Karl Swedbergwww.englishrules.comwww.learningjquery.com On Jul 8, 2008, at 8:31 AM, noon wrote: Anyone have any ideas on this one? It's really stumping me. On Jul 7, 9:15 am, noon [EMAIL PROTECTED] wrote: I don't know why it does this. I am experiencing hidden content (the username label) until the animation is complete and the bump occurs. See it for yourself http://nunyez.googlepages.com/slidedowntest Help appreciated
[jQuery] Re: slideDown hidden portion/bump
I figured it out. The culprit is because I am setting the focus of the username input box. For whatever reason, when I remove this it is slid correctly. On Jul 11, 8:57 am, Liam Byrne [EMAIL PROTECTED] wrote: IE 7 shows scrollbarsmaybe the animation isn't making it big enough to display it properly ? Make it bigger and see what happens. L noon wrote: I wrapped it in a div and slid the div. Still same problem, visible again athttp://nunyez.googlepages.com/slidedowntest On Jul 8, 6:37 pm, Karl Swedberg [EMAIL PROTECTED] wrote: Try wrapping the form in a div and sliding that down. That should work. --Karl Karl Swedbergwww.englishrules.comwww.learningjquery.com On Jul 8, 2008, at 8:31 AM, noon wrote: Anyone have any ideas on this one? It's really stumping me. On Jul 7, 9:15 am, noon [EMAIL PROTECTED] wrote: I don't know why it does this. I am experiencing hidden content (the username label) until the animation is complete and the bump occurs. See it for yourself http://nunyez.googlepages.com/slidedowntest Help appreciated
[jQuery] Re: Some If/Then help
Don't understand when this could occur to make any sense for images being inserted like this without an example, but at any rate... You'll have to think about when and how this is triggered in order for these if statements to be executed because as said, i don't understand switch ($('#main').attr('class')) { case 'aa': insertImg('/path/to/your/images/some_image_for_the_aa_class.jpg'); break; case 'bb': insertImg('/path/to/your/images/some_image_for_the_bb_class.jpg'); break; } function insertImg(path) { $('#main').prepend('img src='+path+'/'); return 0; } On Jul 11, 9:27 am, brendan [EMAIL PROTECTED] wrote: Hey all, I'm using Seamus Leahy's AddAClassNameAtRandomToAnElement.js (http:// moronicbajebus.com/2006/07/30/add-a-class-randomly-from-a-set/) to add a random class to a div, and then trying to insert an image based on the random class name. So if I have div id=main class=aa I'd like to say if #main.aa, then insert image1.jpg; if #main.bb, then insert image2.jpg; etc. Just can't seem to get the syntax right. Or is there a better way to go about this? Any help is very much appreciated
[jQuery] Re: Need Help Filtering Content
First of all, you should be assigning your content links (the ones on the left) classes and not IDs. Not only is it bad practice, but jQuery will stop after it hits the first one. Second of all, $(a).click(function () { var filter = $(this).attr(id); $(li).not(filter).not(.sourceLink).toggle('slow'); }); This snippet is a terrible performer. You have several links on that page, and you are telling jQuery to assign an event to every single one. What you should be doing is $(#sources a). Change your ID's in your list items to classes and something like this should work (yours doesn't specify the hash symbol, #, before the filter, but is faulty anyways as aforementioned) $(#sources a).click(function () { var filter = $(this).attr(class); $(#News li).not(.+filter); }); On Jul 11, 11:22 am, Willie [EMAIL PROTECTED] wrote: I am building a test site with jquery. The site lists links from several rss feeds. On the right side of the page there is a sources legend. I would like to be able to click a source and show only links from that source while the others hide. Then when I click a different source, those links appear, and the others hide. Each link has a ID of the source that it is associated with. I figured it would be easier to toggle them when they had a similar name. I can't get a handle on how to pass along what feed (source) I want to be visible when a user clicks. Can you take a look and give me some advice? http://watercoolertv.com
[jQuery] Re: Button Click
Should you? Well if thats the only javascript on the page there isn't much point in including a library for something like that. However you could do it by saying: // jQuery's document ready $(function() { // grab the button and assign event $(#Cancel).click(function() { window.location.href = /some/url/here; }); }); On Jul 11, 12:39 pm, shapper [EMAIL PROTECTED] wrote: Hello, I have a button which redirects to a page: button class=Cancel type=button onclick=location.href='/Tag/ List?page=1' id=CancelCancel/button Should I remove the onclick from the button and do this with JQuery? And how can I do that using JQuery? Thanks, Miguel
[jQuery] Re: Display (or not display) content based on url hash
You're going to have to read up more on javascript. Mozilla has great online documentation at http://developer.mozilla.org/en/docs/JavaScript , particularly the core guide for you. Also there are some great books out there, O'Reilly's definitive guide can be a little dry at times but does more than explain things. As another hint, I wouldn't recommend reloading the page so that your if or switch statements pick up the hash. I would use a class selector since every link/thumbnail on the left is of class .cross- link. But since class selectors are inefficient I would contain the class selector to the containing ul, #portfolioThumbs. From there I assume you want the image box on the right to slide to the correct photo. You have packed so i couldn't guess the method or function to make it slide, but i'm sure they have it documented. Regardless, you'll need another type of hook to figure out which thumbnail was clicked. Whether it be easily identifiable thumbnail image names (eg, thumb-mayTheCats.gif), the href, another class name, an id, a rel attribute, etc. This example is much more sensible for your current situation Example: (not tested, but should work or close to working) // jQuery's document on ready $(function() { // handle a hash on load var hash_id = document.location.toString().split('#')[1]; // if there wasn't a hash in the url i think hash_id will be null // or false if (hash_id) { // call our custom function with hash_id as first parameter handlePanelSlide(hash_id); } // handle a click event $('#portfolioThumbs .cross-link').click(function() { // call our custom function with the $(this) jQuery object // as a parameter which is the item that was clicked // leave first parameter false as its for hash_id handlePanelSlide(false, $(this)); } }); // end jQuery's document on ready // custom sliding function function handlePanelSlide(id, elem) { // id is false if its a click event // // if click event: // assume these links' ID's were numbered 0 through n // this could also be the href, would have to use // the substring function to remove the hash id = id || $(elem).attr('id'); // this is how many pixels the slider will move var offset = (Number(id) * -600).toString() + 'px'; // move the slider // of course you would want to use the easing or // coda method for a smooth transition, but this // is ultimately what it does $('#slider1 .panelContainer').css('left', offset); } On Jul 8, 7:30 pm, mitchel [EMAIL PROTECTED] wrote: Thank you again. That certainly helped. But I still don't quite understand what to do with the event handler. I gave the links ids of cross-link1, cross-link2, etc. and tried this: $('#cross-link1').click(function() { location.reload(true) }); but it doesn't really do anything. Thanks again, you've been a giant help thus far. On Jul 8, 12:23 pm, noon [EMAIL PROTECTED] wrote: I the if/else statement doesn't seem to be working. You're if statement is using the equals sign as an assignment operator (=) instead of comparison which is double equals (==). Also, it only reads the current hash on a manual refresh of the page. Here is the link if helps any:http://www.mitchmckenzie.com/index.php That piece of javascript is only evaluated when the page loads. If you want you're changes to occur onclick you'll have to assign event handlers to each clickable item -OR- an event handler generically to every click and check its target. Event handler (assuming you've added ID's to each link with the class cross-link): $('#cross-link1').click(function() { // do some javascript }); Generic handler: $('a').click(function() { // you arent sure what was clicked, so lets determine before doing something var the_links_rel_property = $(this).attr('rel'); // $(this) refers to what was clicked switch (the_links_rel_property) { case 'img1': // do something break; case 'img4': // do something break; } }); Hope that helps On Jul 8, 2:51 pm, mitchel [EMAIL PROTECTED] wrote: Thanks! I think that gets me started in the right direction. However, I am still having some issues. Here is what I have so far: var current = (document.location.toString().split('#')[1]) if (current = 1) {document.write( h2Title 1/h2br /pBody text./p ); } else if (current = 2) {document.write( h2Title 2/h2pBody text./p ); } else if (current = 3) {document.write( h2Title 3/h2pBody text./p ); } else if (current = 4) {document.write( h2Title 4/h2pBody text
[jQuery] Re: jMaps and other G* functions
I'm aware that it binds opening to the click function but I want to open without click. On Jul 7, 6:19 pm, Colin Guthrie [EMAIL PROTECTED] wrote: noon wrote: All jMaps functions never seen to return a handler that I can use, but only fire the callback if provided. I used jMaps to add a marker and centered the map. On this newly created marker, how can I get to the other G* methods such as openInfoWindow? When adding a marker you can pass the option pointHTML which will automatically assign a openInfoWindow to the click event of your marker. I've said to Tane (the author) I will help him come up with some more features and better docs on this plugin in the coming weeks/months :) Col
[jQuery] Re: slideDown hidden portion/bump
Anyone have any ideas on this one? It's really stumping me. On Jul 7, 9:15 am, noon [EMAIL PROTECTED] wrote: I don't know why it does this. I am experiencing hidden content (the username label) until the animation is complete and the bump occurs. See it for yourself http://nunyez.googlepages.com/slidedowntest Help appreciated
[jQuery] Re: Display (or not display) content based on url hash
alert(document.location.toString().split('#')[1]) will get you the hash. From there an if statement or a switch/case would serve you. On Jul 8, 8:54 am, mitchel [EMAIL PROTECTED] wrote: Hello. Admittedly, I know very little about jQuery or javascript in general but it seems like it should be able to do what I need it to do fairly easily. I am trying to create a div on a page which would display different content based on the hash in the url. Is there a way to create several hidden divs on a page with the content I want and have a class that makes one visible based on the current hash in the URL? Any ideas on how would I do this? Thanks.
[jQuery] Re: Fade in background image.
I see your problem now. What about using a z-index and have them float on top of each other? This way no element is kicked out of position. I don't know your CSS savvy but having a container for the item with a position of relative, and then the children with absolute positioning would have them absolutely float only inside their container versus the entire page. On Jul 8, 12:47 pm, Liam Byrne [EMAIL PROTECTED] wrote: Maybe try using hoverIntent ? Liam lamy wrote: Hi there! I'd like to create an effect like the one on the jquery Ui website. Someone hovers over an item and is changes its background color smoothly. This is how far I've got: $(.actionmenu).mouseover(function(){ if($(this).css(background-image).length = 4) { var obj = $(this).clone(true); obj.insertAfter(this).hide().css({background-image:url(IMAGE),background-repeat:repeat-y}); $(this).hide(); obj.fadeIn(); } }); $(.actionmenu).mouseout(function(){ if($(this).css(background-image).length 4) { $(this).hide(); $(this).prev(div).fadeIn(); } }); It works. The problem is, that if the user hovers too quickly, the js code can't keep up with cloning and fading in that div so that the item vanishes. Check yourself:http://inaustralia.de/fcms/admin.php?site=entry user/pass:operator Any solutions?
[jQuery] Re: Display (or not display) content based on url hash
I the if/else statement doesn't seem to be working. You're if statement is using the equals sign as an assignment operator (=) instead of comparison which is double equals (==). Also, it only reads the current hash on a manual refresh of the page. Here is the link if helps any:http://www.mitchmckenzie.com/index.php That piece of javascript is only evaluated when the page loads. If you want you're changes to occur onclick you'll have to assign event handlers to each clickable item -OR- an event handler generically to every click and check its target. Event handler (assuming you've added ID's to each link with the class cross-link): $('#cross-link1').click(function() { // do some javascript }); Generic handler: $('a').click(function() { // you arent sure what was clicked, so lets determine before doing something var the_links_rel_property = $(this).attr('rel'); // $(this) refers to what was clicked switch (the_links_rel_property) { case 'img1': // do something break; case 'img4': // do something break; } }); Hope that helps On Jul 8, 2:51 pm, mitchel [EMAIL PROTECTED] wrote: Thanks! I think that gets me started in the right direction. However, I am still having some issues. Here is what I have so far: var current = (document.location.toString().split('#')[1]) if (current = 1) {document.write( h2Title 1/h2br /pBody text./p ); } else if (current = 2) {document.write( h2Title 2/h2pBody text./p ); } else if (current = 3) {document.write( h2Title 3/h2pBody text./p ); } else if (current = 4) {document.write( h2Title 4/h2pBody text./p ); } else if (current = 5) {document.write( h2Title 5/h2pBody text./p ); } else {document.write( h2Title 1/h2br / pBody text./p ); } I the if/else statement doesn't seem to be working. Also, it only reads the current hash on a manual refresh of the page. Here is the link if helps any:http://www.mitchmckenzie.com/index.php Any further help would be greatly appreciated. On Jul 8, 8:00 am, noon [EMAIL PROTECTED] wrote: alert(document.location.toString().split('#')[1]) will get you the hash. From there an if statement or a switch/case would serve you. On Jul 8, 8:54 am, mitchel [EMAIL PROTECTED] wrote: Hello. Admittedly, I know very little about jQuery or javascript in general but it seems like it should be able to do what I need it to do fairly easily. I am trying to create a div on a page which would display different content based on the hash in the url. Is there a way to create several hidden divs on a page with the content I want and have a class that makes one visible based on the current hash in the URL? Any ideas on how would I do this? Thanks.
[jQuery] slideDown hidden portion/bump
I don't know why it does this. I am experiencing hidden content (the username label) until the animation is complete and the bump occurs. See it for yourself http://nunyez.googlepages.com/slidedowntest Help appreciated
[jQuery] Re: How to replace a div content?
Cut and pasted your example. Works fine for me. Do you not have an onready opening function, eg $(function() {}? On Jul 7, 10:04 am, SimDigital [EMAIL PROTECTED] wrote: How could i replace a html content inside the div? I have 1 div (div id=elemini text/div) and everytime i click a button, i want to replace the html content inside the #ELEM to new one. I try to use: jQuery(#button).click(function() { jQuery(#elem).html('bmy text/b'); }); but everytime i click the button, the html is not replaced, resulting something like: bmy text/bbmy text/b What is the solution?
[jQuery] jMaps and other G* functions
All jMaps functions never seen to return a handler that I can use, but only fire the callback if provided. I used jMaps to add a marker and centered the map. On this newly created marker, how can I get to the other G* methods such as openInfoWindow?
[jQuery] Element's inner/children
I have the following HTML structure: div id=new-msgs div class=msg.../div div class=msg.../div /div I have the following code: $('#new-msgs') .appendTo('#prev-msgs') .wrap('div id=p'+pCurrent+'/div'); I want everything inside #new-msgs to be appended to #prev-msgs, and not #new-msgs as well. Using a selector of #new-msgs * loses the hierarchical structure that I want to maintain (div.msg has children). Also using .html() on #new-msgs and then appending +wrapping results in multiple wraps. What's the best way to get the contents of a container and append them somewhere else?
[jQuery] Dynamic event listener?
I have the following code which is clearing the contents of an input box and modifying its css. $('.untouched') .focus(function(){ $(this).val(''); $(this).removeClass('untouched'); $('.add-msg').css('display','inline'); }) .growfield(); After a user enters a message into this box and submits the information some DOM manipulation occurs and another input box with the class of untouched is inserted. However, no onfocus function is tied to this newly inserted node because jQuery isn't actively polling the DOM. Do I have to register an event handler for all clicks and check the target? Does anyone have some sample code for this? Or is there a way to attach the event listener to the new input node during insertion? Without hardcoding onfocus=? If so, is it better to do it this way or handle all clicks?
[jQuery] Toggle(fn,fn1) not working as expected
$(p.more a).click(function() { $(this).parent().siblings(div.overflow).toggle(); $(this).toggle( function() {$(this).html(laquo; Less); alert('1');}, function() {$(this).html(More raquo;); alert('2');} ); }); I am referring to p.more a when mentioning a click. The first time I click no alert is fired. The second time I click 1 is alerted. The third time I click 2 is alerted then 1 is alerted. The fourth time I click 2 is alerted, 1 is alerted, 2 is alerted. And so on. Every time div.overflow is toggled correctly. Why is it recursively operating like this?
[jQuery] Re: Toggle(fn,fn1) not working as expected
Thanks a lot !
[jQuery] IE6 flicker/display problem
http://docs.jquery.com/Tutorials:Live_Examples_of_jQuery This url used to display fine in IE6 (im pretty sure...) and now when I open it, the 2-column content is hidden as soon as jQuery fires (on ready). Why is this happening? I've tested this on two machines running IE6. Is this happening to others as well? Is there a fix? Or at least a culprit?
[jQuery] Re: new to jquery
=== jQuery code === $(function(){ $(a.toggle) .click(function(){ if ( $(this).parent(fieldset).hasClass(collapsed) ) { $(this).parent(fieldset).removeClass(collapsed); } else { $(this).parent(fieldset).addClass(collapsed); } }); }); === HTML === fieldset class=collapsible collapsed group_5 legend a class=toggle href=javascript:void(0)Board Meeting Minutes and Resolutions/a /legend div class=container oddRow div class=doc-date02/13/2007/div div class=doc-titleLetter of Resignation - Vice President of Human Resources eff. 02/28/07/div /div /fieldset === Notes === Doesn't error, but it sure doesn't do anything either. Tried alerting some attributes like class or the typeof $(this).parent(fieldset) but kept coming up with undefined. There isn't any other fieldset above that one. I used to have the code -- if ($ (this.parentNode.parentNode).hasClass(collapsed') -- and it worked. Can't determine what .parent() is doing for me here, besides frustrating. Appreciate any help or advice
[jQuery] new to jquery
Hello, i've been writing javascript for a while now. So, as you can imagine I am struggling just a bit. I browsed a few of the beginner tutorials and didn't see what I was looking for. I understand that methods like .is or .hide are special to the jquery library and you can't access these using regular DOM elements. But I don't want to type $(this.parentNode.parentNode) every time I want to do something to it. Assigning var target = $(this.parentNode.parentNode); still doesn't let me use jquery methods against target. Can someone point me in the right direction here?
[jQuery] Re: code minimization / abstraction
Instead, make your code a static function: Mike, You're a huge help! That all makes much more sense now. Here is what I ended up with: (function( $ ) { $.rjax = function(options) { $.ajax($.extend({ dataType: script, beforeSend: function(xhr) {xhr.setRequestHeader(Accept, text/javascript);} }, options)); } $.remoteLink = function(selector, options) { $(function() { $(selector).click( function() { $.rjax($.extend({ url: this.href }, options)); return false; }); }); }; })( jQuery ); jQuery.remoteLink('#testhref'); Thanks! Joe