[jQuery] Re: How to tell if option is selected when it always defaults to first value?
nick ha scritto: select id=one option value=1 selectedone/option option value=2two/option option value=3three/option /select The right syntax is : option value=1 selected=selectedone/option If there is no selected then it always defaults to first value. How can I tell if the page has loaded and no options have been selected? This is the way the select element works, there is always a selected element, even if you don't interact with the element. You can do this: select id=one option value=0Select an option/option option value=1one/option option value=2two/option option value=3three/option /select selected_val = parseInt($('#one').val()); if( selected_val == 0) { alert('please select an option'); } else { alert('You have selected :'+selected_val); } Bye -- gianiaz.net - web solutions via piedo, 58 - 23020 tresivio (so) - italy +39 347 7196482
[jQuery] center popup scroll/resize probs
So I have a modal popup that is working fairly well, but I have some issues in IE/FF (the only browsers I've tested in so far). One thing is that the popup won't recenter if the browser is resized. The other prob is a bit more difficult to replicate, but I've noticed if my browser window is sized so that I can fit all the bottom of the top row in the screen, but am otherwise scrolled down to the bottom, and then when I click on 1 of the top row items the popup opens with only the bottom half in the viewport. There are more instances of this type of behavior if I play around with scrolling and clicking on items of different distances from the scroll direction. But again, this is hard to predictably replicate, but occurs fairly often. So, essentially, I would like the popup in the center of the viewable area, no matter what. Is this possible? You can see it here: http://development.aquatictraininginstitute.com/schedule/schedule.html Any of the divs that change background on hover will produce the popup on click. The relevant code is here: //centering popup function centerPopup(){ //request data for centering var windowWidth = document.documentElement.clientWidth; var windowHeight = document.documentElement.clientHeight; var popupHeight = $(#popupContact).height(); var popupWidth = $(#popupContact).width(); var mypopup = $(#popupContact); //centering $(#popupContact).css({ position: absolute, top: windowHeight/2-popupHeight/2, left: windowWidth/2-popupWidth/2 }); //only need force for IE6 $(#backgroundPopup).css({ height: windowHeight }); } Thank you for taking the time to look at this :)
[jQuery] Re: Trying to add targetTouches to jQuery event objects
Oops... It's working with: $.each(['touches', 'targetTouches'], function(i, propName){ if ( $.inArray(propName, $.event.props) 0 ) { $.event.props.push(propName); } }); I had the inArray signature wrong and inArray returns the index or -1. On Oct 24, 8:36 pm, dinoboff dinob...@googlemail.com wrote: I tried adding them to $.event.props like this: $.each(['touches', 'targetTouches'], function(){ if (!($.inArray($.event.props, this))) { $.event.props.push(this); } }); But it doesn't seem to work.
[jQuery] Prevent key to change values
Hi every: I have this function: $(input[type='text']:order).keyup(function() { var v = $(this).val().replace(/\D/g,''); // removes non numbers $('#total_buyed').val( v * 2.75 ); }); The function is working correctly but when I press any key the same operation is calculated. How to avoid this? See online at http://jose-couto.com/pintpal4/order_pintpal2.html Cheers and thanks in advance -- ReynierPM
[jQuery] How to select some but not all elements
Hello, I'm building a nested menu where I want to add background colors only to top menu items. I can't change the generated code, so I have to live with the id's and classes as is. Relatively new to jQuery so still not used to filtering my selections carefully—is seems to grab everything. Anyway, I have tried: .is, .content, .filter, and some parent, child stuff, but can't seem to only apply the effect to the top class—it just selects everything. Thoughts? Fundamental concepts welcome. Thanks in advance. —breadwild HTML: ul id=menu li class=topa href=#Menu Item 1/a/li li class=topa href=#Menu Item 2/a ul lia href=#SubMenu A/a/li lia href=#SubMenu B/a/li /ul /li li class=topa href=#Menu Item 3/a/li li class=topa href=#Menu Item 4/a/li /ul JAVASCRIPT: /* seems like I want something like this, but just colors every li with color */ $(#menu li).each(function () { var c = $(this).attr(class); if ( c == top ) { $(#menu li a).css(background-color,tan); } }); /* this works if I want to apply it to li, but I want a */ $(#menu li).each(function () { var c = $(this).attr(class); if ( c == top ) { $(this).css(background-color,tan); } });
[jQuery] Superfish - arrows top menu width
Apologies if this is a css issue and I am barking up the wrong tree... It seems to me that the arrows which are added create an additional width on the menu elements. I would like to specify a fixed width for the top elements in my menu. It appears that the arrows are added automagically by the JS (neat!). I am guessing they are an additional width to anything specified in the skin css. Is there any way to use the arrows but to reserve space for the arrow width, so it doesn't change the top level menu width? I would like to be able to use a fixed width, so that I can use a non- repeating css background image. To complicate matters, I am using Supersubs (maybe I should be using the standard superfish?) Thanks to the developer for producing this cool bit of code!
[jQuery] Using other UI Libraries?
Hello All, Yes. well this is the Jquery group, but i'd figure i'd ask if anyone uses any other UI libraries outside of jquery's UI? I'm currently a server-side coder (doing all my work in php/perl) - but would like to venture out in to the front end. What libraries do people use? Is it just jquery for everything? Or should I be looking for other such libraries depending on my needs?
[jQuery] Jeditable and other plugin question
Hi everyone. I'm a bit of a noob, so please excuse the question! I have a site I'm building that loads a lot of other html files into different divs, depending on buttons you press. Pretty basic stuff... Anyways, I can't seem to get Jeditable and a few other jquery functions to happen in any of these loaded divs. I'm sure this an easy fix for you all! in each file I'm loading, I include the correct jquery-1.3.2.min.js and other js files needed. Firebug shows them loaded correctly. But when I have the script: $('.edit').editable('http://www.example.com/save.php', { indicator : 'Saving...', tooltip : 'Click to edit...' }); (I know I didn't update the post php file yet. I'm waiting for it to actually load first) and in the body of the html/php: echo DIV id=\bio\ class=\edit\ $user_bio/DIV; It does not ever work. Thanks so much for your help! I worked for a while on this, and googled A LOT before posting this. I feel like such an idiot!
[jQuery] Bringing arrows for Clue tip
Hi All, I am trying to bring arrows for the clue tip which i am using for my web site. Even though i have given arrows: true in my js, i am not getting the arrows. Please see below for the code i used and give me your suggestions. My js code : jQuery('a.clueTip').each(function(){ jQuery(this).cluetip({ width: 200, arrows: true, cluezIndex: 999, showTitle: false, cursor: 'pointer', activation: 'click', sticky: true, positionBy: 'fixed', topOffset: 40, leftOffset: -200, local: true, hideLocal: true, attribute: 'href', closePosition: 'bottom', dropShadow: false, closeText: ' X Close' }); }); Clue tip Content in xhtml: div id=clueTipContent This is the content for clue tip /div My link in xhtml: a href=#clueTipContentClick to get Clue Tip/a Thanks, Bharani
[jQuery] Re: How to select some but not all elements
$('#menu li.top a').css('background-color', 'tan'); The selector is just like CSS. On Sun, Oct 25, 2009 at 10:25, breadwild breadw...@gmail.com wrote: Hello, I'm building a nested menu where I want to add background colors only to top menu items. I can't change the generated code, so I have to live with the id's and classes as is. Relatively new to jQuery so still not used to filtering my selections carefully—is seems to grab everything. Anyway, I have tried: .is, .content, .filter, and some parent, child stuff, but can't seem to only apply the effect to the top class—it just selects everything. Thoughts? Fundamental concepts welcome. Thanks in advance. —breadwild HTML: ul id=menu li class=topa href=#Menu Item 1/a/li li class=topa href=#Menu Item 2/a ul lia href=#SubMenu A/a/li lia href=#SubMenu B/a/li /ul /li li class=topa href=#Menu Item 3/a/li li class=topa href=#Menu Item 4/a/li /ul JAVASCRIPT: /* seems like I want something like this, but just colors every li with color */ $(#menu li).each(function () { var c = $(this).attr(class); if ( c == top ) { $(#menu li a).css(background-color,tan); } }); /* this works if I want to apply it to li, but I want a */ $(#menu li).each(function () { var c = $(this).attr(class); if ( c == top ) { $(this).css(background-color,tan); } });
[jQuery] Re: show/hide problem
If a.more is a child of the div, use this code. $(document).ready(function() { $(div.featured-cell-padding).mouseenter(function(){ $(this).find(a.more).show(); }); $(div.featured-cell-padding).mouseleave(function(){ $(this).find(a.more).hide(); }); }); On Oct 25, 1:13 am, Daniel Donaldson d8nieldonald...@gmail.com wrote: I am trying to have a image (link button) appear within a div on mousenter for the div, and disappear on mouseleave. I have this working in the following code as expected, but I only want it to apply to the specific div that is being entered/left. The way I have it right now it applies to the class, so every div with the class will trigger the function, which is not the desired effect : ( What I would like to have it do is have the image show/hide only within the specific div that is being entered/left. Due to the nature of the project, I cannot simply apply id's to the divs as a solution. The code follows, I apologize that I cannot provide a live link, it isn't online yet, but I have pasted the code below: // $('a.more').hide(); // $('div.featured-cell-padding').mouseenter(function() { $('a.more').show(); return false; }); // $('div.featured-cell-padding').mouseleave(function() { $('a.more').hide(); return false; }); }); thanks for any help/insight/words of wisdom :)
[jQuery] Re: clueTip display inconsistently
You're selecting only the third link with class=jt: $('a.jt:eq(2)') If you want all of them to show the cluetip on hover, remove the :eq(2) part of the selector: $('a.jt') --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Oct 23, 2009, at 5:19 PM, wendy.constantine wrote: I've encountered some inconsistency in how the clue tip plugin displays. In most cases, it works perfectly using the JTip theme, yet when there are multiple links on a page, the links lowest on the page almost surely do not display a tip at all (except for the standard browser tooltip). And in some cases, the style changes entirely while using the same class. Here is a link to a sample document: http://d-college.cengage.com/art/0495799874_kleiner/student/bonus/ch04/04_08A.html In all cases, what I'm trying to accomplish is an image rollover with title. The hrefs and parameters are all constructed the same, and what's more puzzling is that the same href would work fine if placed at the top of the document. This is the jquery used: $('a.jt:eq(2)').cluetip({ cluetipClass: 'jtip', arrows: true, dropShadow: true, height: 'auto', sticky: true, waitImage: true, closeText: 'img src=../../../jscript/images/cross.png alt=close /', positionBy: 'bottomTop' }); And here's a sample href: a class=jt href=javascript:void(0); rel=../ch03/thumbs/ 0312A.jpg title=Seated statues of Rahotep and Nofret, from their mastaba at Maidum, Egypt, Fourth Dynasty Any help would be appreciated. Thanks, Wendy
[jQuery] Re: Superfish - arrows top menu width
if you look at element widths in css there are no explicit widths set. Default sizing is established by padding on a tags arrows are absolute positioned so setting width to a tags might help. Per your first line, it's all about css Bruce A wrote: Apologies if this is a css issue and I am barking up the wrong tree... It seems to me that the arrows which are added create an additional width on the menu elements. I would like to specify a fixed width for the top elements in my menu. It appears that the arrows are added automagically by the JS (neat!). I am guessing they are an additional width to anything specified in the skin css. Is there any way to use the arrows but to reserve space for the arrow width, so it doesn't change the top level menu width? I would like to be able to use a fixed width, so that I can use a non- repeating css background image. To complicate matters, I am using Supersubs (maybe I should be using the standard superfish?) Thanks to the developer for producing this cool bit of code!
[jQuery] Re: How to select some but not all elements
Thanks! That got me on the right path, Leonardo. Ended up making each background a different color: var colors = new Array(#FC9596,#AF79BB,#A5C0DA,#D2E746); $(#menuh li.top a).each(function (i) { $(this).css(background-color,colors[i]); }); On Oct 25, 5:20 pm, Leonardo K leo...@gmail.com wrote: $('#menu li.top a').css('background-color', 'tan'); The selector is just like CSS. On Sun, Oct 25, 2009 at 10:25, breadwild breadw...@gmail.com wrote: Hello, I'm building a nested menu where I want to add background colors only to top menu items. I can't change the generated code, so I have to live with the id's and classes as is. Relatively new to jQuery so still not used to filtering my selections carefully—is seems to grab everything. Anyway, I have tried: .is, .content, .filter, and some parent, child stuff, but can't seem to only apply the effect to the top class—it just selects everything. Thoughts? Fundamental concepts welcome. Thanks in advance. —breadwild HTML: ul id=menu li class=topa href=#Menu Item 1/a/li li class=topa href=#Menu Item 2/a ul lia href=#SubMenu A/a/li lia href=#SubMenu B/a/li /ul /li li class=topa href=#Menu Item 3/a/li li class=topa href=#Menu Item 4/a/li /ul JAVASCRIPT: /* seems like I want something like this, but just colors every li with color */ $(#menu li).each(function () { var c = $(this).attr(class); if ( c == top ) { $(#menu li a).css(background-color,tan); } }); /* this works if I want to apply it to li, but I want a */ $(#menu li).each(function () { var c = $(this).attr(class); if ( c == top ) { $(this).css(background-color,tan); } });
[jQuery] Re: How to know which button is clicked
Use a variable? var buttonClicked = ''; $(#delete).click(function(){ buttonClicked ='delete'; . }) $(#view).click(function(){ buttonClicked ='view'; . }) submitHandler: function(form) { if(buttonClicked == 'delete') {//do delete} else if (buttonClicked == 'view') {//do view} } } On Oct 24, 6:20 am, mathie trung...@gmail.com wrote: Hello, I have a form with two buttons: Delete and View. A checkbox is required for all actions. Validation happens when a button is clicked. If it's View, it is just a normal operation. However, if it's Delete, if the form is valid, it then needs to show a confirmation before form submission via custom handler (submitHandler). submitHandler: function(form) { if (confirmDelete()) { form.submit (); } } Problem: How do I know if the button is Edit or Delete inside submitHandler? The function above open the dialog even for View button. Thanks for any suggestion.
[jQuery] Superfish ?
Im newbie... trying to implement Superfish vertical menu with Wordpress. Have working, kind of... shows the whole menu structure, just not indicator arrows. Paths all ok in css. May be related... What is Hover Class? Default is set to sfHover. .. i assume i need to change something in WP but not sure what... THANKS for any help DRS
[jQuery] Re: Bringing arrows for Clue tip
Is this really the link you're using in your html? a href=#clueTipContentClick to get Clue Tip/a If so, you shouldn't be getting the cluetip at all, since you're using 'a.cluetip' as your selector. The arrows are images referenced in the jquery.cluetip.css stylesheet. If you don't have those images in the images directory within the directory where that stylesheet is located, they won't show up. Hope that helps --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Oct 25, 2009, at 11:04 AM, Bharanidharan wrote: Hi All, I am trying to bring arrows for the clue tip which i am using for my web site. Even though i have given arrows: true in my js, i am not getting the arrows. Please see below for the code i used and give me your suggestions. My js code : jQuery('a.clueTip').each(function(){ jQuery(this).cluetip({ width: 200, arrows: true, cluezIndex: 999, showTitle: false, cursor: 'pointer', activation: 'click', sticky: true, positionBy: 'fixed', topOffset: 40, leftOffset: -200, local: true, hideLocal: true, attribute: 'href', closePosition: 'bottom', dropShadow: false, closeText: ' X Close' }); }); Clue tip Content in xhtml: div id=clueTipContent This is the content for clue tip /div My link in xhtml: a href=#clueTipContentClick to get Clue Tip/a Thanks, Bharani
[jQuery] Re: cluetip memory leak
Wow, I wasn't aware of this memory leak at all. Thanks for bringing it to my attention. I had no idea that storing the current element in a variable would cause a leak. That's a really common thing to do in jQuery plugins. I wonder if the memory issue has been encountered in other plugins and how it has been dealt with. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Oct 22, 2009, at 7:49 PM, Andrew Tan wrote: Hi, I have been tracking down a memory leak in my web app which dynamically removes and adds anchors which have cluetip tooltips attached and I think that I may have narrowed down the problem to the main closure in cluetip which attaches the cluetip to the node (line 32: var link = this, $this = $(this);). I have been running the following script in SIEV with a modified version of jquery 1.3.2 with the following fix which allows the cluetip elements to be removed. However, the anchor nodes become orphaned as there is still 1 reference to them after the cluetip nodes are removed? If I change line 32 of the cluetip source to the following for testing purposes: var link = $('br'), $this = $('br'); The anchors are freed but the 'br' nodes start building up. Therefore, I was wondering if anyone knows how I can work around this problem? or if I am simply not releasing the resources correctly? Attached Scripts and Source: jQuery modification. After line 1247 insert the following before the closing curly brace (http://markmail.org/message/ cfi4bvfjc3m6ww6k#query:jquery%20memory%20leak%20in%20remove%20and %20empty+page:1+mid:tapc7zt3cwl6rw4f+state:results): this.outerHTML = ; Example Script: html head link rel=stylesheet type=text/css href=jquery.cluetip.css/ script type=text/javascript src=jquery-1.3.2.js/script script type=text/javascript src=jquery.cluetip.js/script script type=text/javascript $(document).ready(function() { setInterval(resetCluetip, 1000); }); function resetCluetip() { $('a').each(function() { $(this).cluetip('destroy'); $(this).unbind().remove(); }); $('#cluetip*').unbind().empty(); $('body').html('a href=# class=contextMenu title=title| bodyanchor one/abr'); $('a').each(function() { $(this).cluetip({splitTitle: '|'}); }); } /script /head body /body /html
[jQuery] Re: ClueTip focus/blur trouble
Hi Shawn, Here is what I'd probably do: After you call $this.cluetip( ...), unbind the blur event: $this.unbind('blur.cluetip'); Then you can handle the closing of the clueTip however you want using $ (document).trigger('hideCluetip'); Maybe something like this: $('#cluetip').hover(function() { $(this).data('hovered', true); }, function() { $(this).removeData('hovered'); }); $this.blur(function() { setTimeout(function() { if (!$('#cluetip').data('hovered')) { $(document).trigger('hideCluetip'); } }, 100); }); You'll have to add the click handler to the list items, too, of course. Hope that gets you on the right track. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Oct 22, 2009, at 6:08 PM, Shawn wrote: Hi Gang. I'm working with ClueTip and have run into some oddities. In particular, I want to show ClueTip when a textbox receives focus. The source shows me that I can use activation:'focus' for this and that will result in the cluetip showing on focus and disappearing on blur. Showing the cluetip is working fine, blurring is not. The code I have is this: $this.cluetip({ activation: 'focus', local: true, showTitle: false, sticky: true, mouseOutClose: true, arrows: true, closeText: strongX/strong, closePosition: title }).focus( function (){ $ (opts.source).children().removeClass(opts.hover); }); The .focus() method that I have here is simply resetting the classes on the items the user may interact with. I'm using ClueTip to provide a rapid selection tool - similar to a drop down list, but without the drop down list UI. (large number of options, needing HTML for formatting, etc.) The idea is that when the cursor arrives at the textbox, the cluetip shows and the user can use either the mouse to click an item, or the up/down keys and enter to do the same. Where I am running into problems is with the click selection. If I add a blur handler to the above code: .blur( function () { $(document).trigger('hideCluetip'); }) then things work well for keyboard selection and blurring, but if I click instead, the click event never happens. Because, clicking on the cluetip triggers the blur of the textbox which closes the cluetip before the click can be handled. I suspect this may be partly why the onblur isn't working within ClueTip as well - the logistics seem rather complex... So I'm looking for suggestions on how to get this running properly. OR for a plugin that provides similar functionality already. Thanks for any feedback. Shawn
[jQuery] Re: cluetip memory leak
The memory is released when you refresh the page. However, the users of my web app will be using the same page for 8+ hours a day and the page will most likely not be refreshed since all the updates are displayed and retrieved via ajax and jquery.
[jQuery] Re: Prevent key to change values
Put the calculation logic in blur event? $(input[type='text']:order).blur(function(){ $('#total_buyed').val( v * 2.75 ); }) On Oct 26, 4:18 am, ReynierPM rper...@uci.cu wrote: Hi every: I have this function: $(input[type='text']:order).keyup(function() { var v = $(this).val().replace(/\D/g,''); // removes non numbers $('#total_buyed').val( v * 2.75 ); }); The function is working correctly but when I press any key the same operation is calculated. How to avoid this? See online athttp://jose-couto.com/pintpal4/order_pintpal2.html Cheers and thanks in advance -- ReynierPM
[jQuery] Re: How Stop Animation Works?
you might need to use the clearQueue and gotoEnd arguments in the .stop() method: .stop(true, true) --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Oct 24, 2009, at 12:24 AM, Stan wrote: Dear All, I have an object with mouse over and mouse out events. It fires display certain other box (almost like tooltip): box.fadeIn(slow) box.fadeOut(slow) It works absolutely fine unless mouse passed over the object without intention to stop. Then it triggers full scenario, complete fading in and then complete fading out, which is of course is not desired here. I have made amendments such as: box.stop().fadeIn(slow) box.stop().fadeOut(slow) It does the thing but only once or twice, after that whole animation stopped working. No more reaction on mouse even if mouse remains over the object. Do I use stop() method wrongly? I want to mention that unlike tooltip I need action to start right away without any timeout though in slow movement. I don't mind slight flicker when mouse passes. Currently I had to degrade to show() and hide() but could it be done with animation? Thanks in advance.
[jQuery] Re: ClueTip focus/blur trouble
Thanks Karl. I'll look at this more in a bit. but from what I can see I think you have a solution for me.. Shawn Karl Swedberg wrote: Hi Shawn, Here is what I'd probably do: After you call $this.cluetip( ...), unbind the blur event: $this.unbind('blur.cluetip'); Then you can handle the closing of the clueTip however you want using $(document).trigger('hideCluetip'); Maybe something like this: $('#cluetip').hover(function() { $(this).data('hovered', true); }, function() { $(this).removeData('hovered'); }); $this.blur(function() { setTimeout(function() { if (!$('#cluetip').data('hovered')) { $(document).trigger('hideCluetip'); } }, 100); }); You'll have to add the click handler to the list items, too, of course. Hope that gets you on the right track. --Karl Karl Swedberg www.englishrules.com http://www.englishrules.com www.learningjquery.com http://www.learningjquery.com On Oct 22, 2009, at 6:08 PM, Shawn wrote: Hi Gang. I'm working with ClueTip and have run into some oddities. In particular, I want to show ClueTip when a textbox receives focus. The source shows me that I can use activation:'focus' for this and that will result in the cluetip showing on focus and disappearing on blur. Showing the cluetip is working fine, blurring is not. The code I have is this: $this.cluetip({ activation: 'focus', local: true, showTitle: false, sticky: true, mouseOutClose: true, arrows: true, closeText: strongX/strong, closePosition: title }).focus( function (){ $(opts.source).children().removeClass(opts.hover); }); The .focus() method that I have here is simply resetting the classes on the items the user may interact with. I'm using ClueTip to provide a rapid selection tool - similar to a drop down list, but without the drop down list UI. (large number of options, needing HTML for formatting, etc.) The idea is that when the cursor arrives at the textbox, the cluetip shows and the user can use either the mouse to click an item, or the up/down keys and enter to do the same. Where I am running into problems is with the click selection. If I add a blur handler to the above code: .blur( function () { $(document).trigger('hideCluetip'); }) then things work well for keyboard selection and blurring, but if I click instead, the click event never happens. Because, clicking on the cluetip triggers the blur of the textbox which closes the cluetip before the click can be handled. I suspect this may be partly why the onblur isn't working within ClueTip as well - the logistics seem rather complex... So I'm looking for suggestions on how to get this running properly. OR for a plugin that provides similar functionality already. Thanks for any feedback. Shawn