[jQuery] Filter List Items w/ Sub-Lists
I have selected a list that contains sub-lists. Now, I'd like to search for the list items that contain sub-lists (but not including the sub-list-items). I think the example below will explain what I'm trying to do. HTML: ul class=start-here liDo Not Need/li liNEED THIS ITEM ul liDo Not Need/li liDo Not Need/li /ul /li liDo Not Need/li liNEED THIS ITEM ul liDo Not Need/li liDo Not Need/li liNEED THIS ITEM ul liDo Not Need/li liDo Not Need/li /ul /li liDo Not Need/li /ul /li liDo Not Need/li /ul jQuery: $('.start-here li').filter(':has(li)').append('span class=ui-icon ui- icon-plus/span'); The above jQuery statement selects the correct li but also all child li's, which I do not want.
[jQuery] Using each() for multiple $('table') elements
I know this is a easy fix, I'm doing something wrong... I've selected multiple tables and tried to use each for applying cornering to each table. Inside the callback function, I try to find the first/last table cells to apply cornering for each corner. However, when there are multiple tables it looks at _all_ the tr elements for the first/last rows. See example code: // Add cornering to tables $('table.corner-me').addClass('ui-corner-all').each(function(){ var $table = $(this); $table.find('tr:first :first-child').addClass('ui-corner-tl'); $table.find('tr:first :last-child').addClass('ui-corner-tr'); $table.find('tr:last :first-child').addClass('ui-corner-bl'); $table.find('tr:last :last-child').addClass('ui-corner-br'); }); table class=corner-me tr thHeader 1/th thHeader 2/th /tr tr tdData A1/td tdData B1/td /tr tr tdData A2/td tdData B2/td /tr /table table class=corner-me tr tdData A1/td tdData B1/td /tr tr tdData A2/td tdData B2/td /tr tr tdData A3/td tdData B3/td /tr /table
[jQuery] Tablesorter UI Theme Support
This is a double post, at least going to be a double post from in the jQuery Plugin list. I'm being moderated yet on that list, and it doesn't seem to get much activity. -- Hi, I'm going to post this here since the Tablesorter developer hasn't gotten back to me yet. I took a copy of the latest version in SVN and modified it to have jQuery UI Theme support. It seems to work very well and anyone is welcome to use it. Here are the features: New Options -- uiTheme: boolean true/false (default false) uiThemeIconAsc: string 'icon-class-name' (default 'ui-icon-carat-1- s') uiThemeIconDesc: string 'icon-class-name' (default 'ui-icon-carat-1- n') uiThemeIconSort: string 'icon-class-name' (default 'ui-icon-carat-2-n- s') New Widgets --- zebraStripes - same thing as zebra, just vertically checkers - just what it sounds like Note: zebra and zebraStripes can be used together but zebra must be first Download --- I was hoping this would be included into tablesorter so I just threw up the modified version on my work site for now. Let me know what you think! http://www.stma.k12.mn.us/tablesorter.zip
[jQuery] CSS Style Property Assigned by Class
For some reason I cannot get jQuery.css('name') to return a style property that was assigned by a class. However, it returns the property if it was assigned by style=. Has anyone else run into this issue? Bug? Here is my test code: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/ TR/html4/strict.dtd htmlhead titleCSS Test/title style type=text/css .apply-border { border: 1px solid blue; } /style script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3/ jquery.min.js type=text/javascript/script script type=text/javascript $(document).ready(function() { $('#byStyle').append($('#byStyle').css('border')); $('#byClass').append($('#byClass').css('border')); }); /script /headbody p id=byStyle style=border: 1px solid green;Border applied by style = /p p id=byClass class=apply-borderBorder applied by class = /p /body/html
[jQuery] Re: Ajax timeout doesn't call error function?
I tried that without the if (see code above) and the error isn't thrown. I also used a Jquery JSONP library, and there the error is thrown (immediately) when the user is offline. I'm trying to get that same behavior. Adding my own timeout has as disadvantage that I'd have to wait for that, while the error should happen immediately when the user is offline. Any idea's are welcome. Thanks! PanMan. On Apr 20, 4:02 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: A timeout is not considered an error. No. It's an error. Do the following: timeout: 1, error: function(d,msg) { if (msg==timeout) { alert(Ops! Could not load stuff - A timedout error occur); } else { alert(Could not load stuff - Another errorType occur); }, ... Maurício -Mensagem Original- De: Martijn Houtman Para: jquery-en@googlegroups.com Enviada em: segunda-feira, 20 de abril de 2009 10:47 Assunto: [jQuery] Re: Ajax timeout doesn't call error function? Hey PanMan, On Apr 20, 2009, at 12:28 PM, PanMan wrote: This works, but the error is never thrown. If I change the URL to something that's broken, I do get the error message, but on timeout it never happens. Am I doing anything wrong? Or is this a bug somewhere? No, this is not a bug. A timeout is not considered an error. You'd be better off using manual timeouts or use some sort of ajax manager. For my setup I used a combination of both, in which I set a timer with a certain value for connection timeout, and clear that timer when I actually receive data. The timer calls an anonymous function which aborts the ajax request (and in my case, calls the request again). This works fine for me. Regards, -- Martijn.
[jQuery] Ajax timeout doesn't call error function?
Hi! I'm trying to setup an ajax call which throws an error on timeout. function getXMLfeed(url, target) { $.ajax({ url: url, timeout: 1, error: function(d,msg) { alert(Could not load stuff); }, success: function(data){ var json = $.xml2json(data); gotdata(json, target); } }); This works, but the error is never thrown. If I change the URL to something that's broken, I do get the error message, but on timeout it never happens. Am I doing anything wrong? Or is this a bug somewhere? Thanks! PanMan.
[jQuery] Re: Ajax timeout doesn't call error function?
On Apr 20, 3:03 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: Hi! I'm trying to setup an ajax call which throws an error on timeout. ... timeout: 1, error: function(d,msg) { alert(Could not load stuff); }, ... This works, but the error is never thrown. If I change the URL to something that's broken, I do get the error message, but on timeout it never happens. --- Are you sure that your request spends more than 10s ? Maurício Hi! I tried this while offline. The jquery JsonP lib times-out directly (which would be my preference). But I'm sure nothing loads in 10s, since I'm offline. (this is for an app over flaky mobile connections). PanMan.
[jQuery] Select Last li
Sounds simple but I cannot get it to work. Here is the structure. ul class=list lia href=#Abc/a/li lia href=#Abc/a ul lia href=#Abc/a/li lia href=#Abc/a/li lia href=#123/a/li /ul /li lia href=#Abc/a/li lia href=#Abc/a/li /ul I want to get the last a in the _sub_ list. Here is what I've tried with no success. Ideas? $('.list li li:last a').addClass('last-li'); $('.list li ul li:last a').addClass('last-li'); $('.list li:has(ul) li:last a').addClass('last-li');
[jQuery] jQuery.getScript and Browser Cache
Are browsers able to cache calls from jQuery.getScript (http:// docs.jquery.com/Ajax/jQuery.getScript)? I'm just trying to determine either to use that or just use HTML script tags to get jQuery plugin files and such. Would like the most officiant option. The reason being, I'd like to break out the first option into a separate JavaScript file, like a bootstrap file. Option 1: script type=text/javascript src=/_assets/js/jquery.js/script script type=text/javascript $.getScript(/_assets/js/jquery.ui.all.js); $.getScript(/_assets/js/jquery.hoverIntent.js); /script /script Option 2: script type=text/javascript src=/_assets/js/jquery.js/script script type=text/javascript src=/_assets/js/jquery.ui.all.js/ script script type=text/javascript src=/_assets/js/ jquery.hoverIntent.js/script
[jQuery] Re: jQuery.getScript and Browser Cache
True, combining files would be the best option. I'm thinking in the case where I would like to detect weather or not a specific plugin is required. So if x element exists then include x plugin. Just looking for something like the Dojo require, which loads its' modules. Another option I thought of is to $('head').append('script .../ script'); On Nov 11, 3:13 pm, Michael Geary [EMAIL PROTECTED] wrote: Are you going to always be loading these .js files into your page? If so, the most efficient option by far is to concatenate all of them into a single .js file that you load with a single script tag. Maybe explain more about why you want a bootstrap file, and what exactly you want it to do? -Mike From: Panman Are browsers able to cache calls from jQuery.getScript (http:// docs.jquery.com/Ajax/jQuery.getScript)? I'm just trying to determine either to use that or just use HTML script tags to get jQuery plugin files and such. Would like the most officiant option. The reason being, I'd like to break out the first option into a separate JavaScript file, like a bootstrap file. Option 1: script type=text/javascript src=/_assets/js/jquery.js/script script type=text/javascript $.getScript(/_assets/js/jquery.ui.all.js); $.getScript(/_assets/js/jquery.hoverIntent.js); /script /script Option 2: script type=text/javascript src=/_assets/js/jquery.js/script script type=text/javascript src=/_assets/js/jquery.ui.all.js/ script script type=text/javascript src=/_assets/js/ jquery.hoverIntent.js/script
[jQuery] Effect Like slideUp/Down
I cannot for the life of me figure this out. I know it must be easy, just not finding the solution. I'd like to toggle() something and use the slide effect. However, I don't like how the UI slide effect works. It slides the content out of view then brings whatever was below up. I'd rather have whatever is below slide up with the content. Compare how .hide(slide, {direction: up}, slow) and .slideUp(slow) differ. I tried using the core toggle() with slideUp/Down but that is not reliable. Thanks for any input!
[jQuery] Re: List ul slideDown/Up Menu
Hi, thanks for the reply. I've uploaded what I had to my test site. http://admin.stma.k12.mn.us/_assets/template/new.tpl.html I thought the code would get the child ul, entire sub-menu, and slide up/down. Also looked at Accordion but thought it was more than I needed. Since, I already have the menu working with CSS I just wanted to add the slide down/up feature. On May 8, 7:29 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, Panman! Welcome. It would help if you posted a link to your work page. Without seeing your actual code, it looks like you have every second- child li sliding up down with every mouseover, which would kind of explain the problem ;) To make life easy you could use the jQuery UI Accordion plugin; seehttp://ui.jquery.com/andhttp://bassistance.de/jquery-plugins/jquery-plugin-accordion/ . Alternatively, use an each or an iteration or a class/id to allow jQuery select the item you want expanded. Panman wrote: Hi, new to jQuery and very impressed. I already have a CSS menu that shows/hides a list menu. However, I'd like to add more dynamics and have the sub menus slide down and back up. So using the below code, I've got it to slide down and up, but repeatedly. It seems like it wants to keep sliding for each li and even multiple times per hover. Seems like it should be easy... Any ideas? $('#Main_Nav ul li').mouseover(function() { $(this).children('ul').slideDown('normal'); }).mouseout(function() { $(this).children('ul').slideUp('normal'); }).end(); Here is a link to the type of CSS menu I have: http://meyerweb.com/eric/css/edge/menus/demo.html However, I only have two levels of lists. Ex: ul liabc/li liabc ul liabc/li liabc/li /ul /li liabc/li /ul
[jQuery] Re: List ul slideDown/Up Menu
Getting closer! I changed from using the mouseover() and mouseout() to hover(). That now seems to be working properly. The only issue at this point is that it doesn't slide down on the first hover. When the page loads and the mouse is over the li it just shows the list as the CSS does. Then when the mouse goes out it will slideUp() and any additional hovers it'll slideDown/Up. I have enclosed it in a ready() function... Test site is updated. Thanks for any help! $(document).ready(function() { $('#Main_Nav ul li').hover( function (e) { $ (this).children('ul').slideDown('normal'); }, function (e) { $(this).children('ul').slideUp('normal'); } ); } ); On May 9, 11:25 am, andrea varnier [EMAIL PROTECTED] wrote: not sure but you could try something like this, to get more specific... $('#Main_Nav li:has(ul)').mouseover(function(e) { e.stopPropagation(); $(this).children('ul').slideDown('normal');}).mouseout(function(e) { e.stopPropagation(); $(this).children('ul').slideUp('normal'); }); btw you don't need the .end() method at the end ;)
[jQuery] Re: List ul slideDown/Up Menu
Andrea, when I changed to hover() the stopPropagation() effected negatively. Once I removed that it started working ok. Also, what is variable e when passing it to the function? Thanks On May 9, 11:25 am, andrea varnier [EMAIL PROTECTED] wrote: not sure but you could try something like this, to get more specific... $('#Main_Nav li:has(ul)').mouseover(function(e) { e.stopPropagation(); $(this).children('ul').slideDown('normal');}).mouseout(function(e) { e.stopPropagation(); $(this).children('ul').slideUp('normal'); }); btw you don't need the .end() method at the end ;)
[jQuery] List ul slideDown/Up Menu
Hi, new to jQuery and very impressed. I already have a CSS menu that shows/hides a list menu. However, I'd like to add more dynamics and have the sub menus slide down and back up. So using the below code, I've got it to slide down and up, but repeatedly. It seems like it wants to keep sliding for each li and even multiple times per hover. Seems like it should be easy... Any ideas? $('#Main_Nav ul li').mouseover(function() { $(this).children('ul').slideDown('normal'); }).mouseout(function() { $(this).children('ul').slideUp('normal'); }).end(); Here is a link to the type of CSS menu I have: http://meyerweb.com/eric/css/edge/menus/demo.html However, I only have two levels of lists. Ex: ul liabc/li liabc ul liabc/li liabc/li /ul /li liabc/li /ul