[jQuery] Re: add class to row object of table
Me-thinks your code is making an array of custom objects not TR elements. Each object in your array has a .row property which does refer to a TR element, so $(row.row).addClass(bold) might work. That said, I'd be more inclined to use jQuery to do the work... For example: (Note I've used a $ prefix on variables to help indicate those that are jQuery objects) var $columnCells = $(#srTableTBODYTRTD:nth-child(1)); Then to loop through them: $columnCells.each(function(){ // Or $columnCells.parent(TR).each... if( -whatever- ){ $(this).parent(TR).addClass(bold); } }) Hope this helps. George The problem is later when I'm trying to add or remove class in jquery fashion like $(row).addClass(bg_litegray) its giving some error. I think I'm doing it wrong. Can anyone of you suggest me how to use this row similar to $(#srTable tbody tr) in jquery so that I can add class, remove class, apply filter like $(row).filter('[EMAIL PROTECTED]refine]')etc...
[jQuery] Re: jQuery Ajax Bugs?
On Aug 20, 1:49 pm, F8R [EMAIL PROTECTED] wrote: I have use jQuery to send AJAX call to PHP script using POST. It's always execute error function callback. snip Check the param order. You're putting error function in another param. -- ?php echo 'Just another PHP saint'; ? Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/
[jQuery] Re: .change() and IE bug
On Aug 20, 6:13 pm, Eridius [EMAIL PROTECTED] wrote: I have now just tried destination.load('/lib/ajax/price_buster.php', {'get': 'destination'}); destination.bind('change', function() { snip Add bind in load's callback, otherwise, you won't be having elements to bind. Or use LiveQuery plugin. -- ?php echo 'Just another PHP saint'; ? Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/
[jQuery] Re: Fwd: jQuery and UTF8
On Aug 20, 11:11 pm, barophobia [EMAIL PROTECTED] wrote: On 8/20/07, Bil Corry [EMAIL PROTECTED] wrote: snip Based on your information I think my problems will be solved once I get the server to serve PHP as UTF-8 (I think I can do this via .htaccess). Either: 1. Save the file in UTF-8 2. or send the UTF-8 charset header via header(); browser should handle -- ?php echo 'Just another PHP saint'; ? Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/
[jQuery] Re: jQuery Ajax Bugs?
F8R wrote: I have use jQuery to send AJAX call to PHP script using POST. It's always execute error function callback. I check using FireBug Firefox extention, the passed XMLHTTPRequest to error function callback has some of this value : readyState : 4 status : 200 responseText : {The expected response} statusText : OK Here some of my code : $.ajax({url:'inc/ msgboard.php'.url,type:'POST',dataType:'html',data:'name=F8R', success : function(passed) { } }, complete : function() { }, error : function(err) { alert(err ? err.responseText : 'Request GAGAL, silakan coba lagi beberapa saat.\nContent tidak ter-Update.'); } }); I'm using Windows XP and Apache 2.2 as test. Can someone help me ? The PHP header was set to text/html. Here's an error: url:'inc/msgboard.php'.url ^ --Klaus
[jQuery] Re: Tablesorter 2.0
This is interesting. I was thinking along these lines but was interested to know how you - being the designer - would implement it. Thanks for you help. I'll tell you what I am working on at the moment. I'd be interested to know what you thoughts are, if you have any pointers or have thought about this kind of thing yourself. I have a sortable Document History table for a collaborative document-writing app (eg the table has columns such as Doc name, last mod timestamp, last user, link to D/L the doc). There will eventually be history tables for multiple documents on one page. I am mashing up your Tablesorter with Remy Sharp's Spy. What has been interesting so far is: * reloading all the widgets after an ajax prependage to the table. I am having trouble deciding the best way to update the widgets this when the 'update' event is triggered. * These other widgets bind clicks events to elements in the new table rows as well as doing things like zebra striping the rows. This makes the browser go crazy as its trying to handle events and adding rows all at once. * The point of mashing other plugins with the tablesorter using the widget system:- Currently the mashed widget has to be added before the settings for for said plugin are added to tablesorter. ie $(table).tablesorter({ widgets: [mashWidget], widgetMashSettings : { url : 'somejson.php', callback : insertJsonIntoTable, timeout : 3000 } }); I haven't even started on resorting the table after rows are added yet... This widget thing is so exciting to me. Hopefully it will encourage a whole load of activity form the community - a widget repository might be nice! cheers Luke Oh yeah - and I have a plan dynamically loading date parsers based on locale settings. On 20 Aug, 23:17, Christian Bach [EMAIL PROTECTED] wrote: Hi Lukek, I took an other approach to this. Check out:http://tablesorter.com/docs/example-extending-defaults.html Regards Christian 2007/8/20, lukek [EMAIL PROTECTED]: Been having a further poke around. I have done what Christian suggested and merged the widgets and parser arrays of this.config with those in settings. However now I have realised the constructor is being called twice - or the number of levels of inheritance. So many options not sure what to do... On Aug 20, 9:33 am, lukek [EMAIL PROTECTED] wrote: Thanks for getting back Christian - only just seen you post. I look forward to the fix. I will tinker with it and see what I come up with until then. By the way I had another question. -- In the unpacked version of the latest script your comment on line 555 says apply easy methods that trigger binded events. Does this mean I can insert function calls in here - ie around line 560? I say this because I have added a call to applyWidget() as I reckon all the widgets should be reloaded when the update event is triggered - eg after I insert rows I want to reapply the zebra widget. Unless I missed something or your plan was to control this action in some other way. Thanks Luke On Aug 17, 10:36 pm, Christian Bach [EMAIL PROTECTED] wrote: Lukek, I will supply a fix for this after the weekend. If you cant wait that long a tip is that if this.config exists that should be extended instead of the defaults. /christian 2007/8/17, lukek [EMAIL PROTECTED]: Hi, I have just been playing with the newTablesorter2.0. Thanks Mr Bach! Great piece of work. I am having problems getting tables to inherit widgets. I am not sure if its the way $.extend() merges arrays when passing the settings object to thetablesorter.construct() function or what but when I add more widgets it seems to overwrite the ones I added previously. EXAMPLE: table class=data id=myTable1 .../table table class=data id=myTable2 .../table script $(table.data).tablesorter( { widgets: [ 'zebra', 'someWidget', 'anotherWidget'] } ); $(#myTable2).tablesorter( { widgets: [ 'completelyDiffWidget' ] } ); /script Do you see what I'm doing? #myTable2 should now have all four widgets. But that's not what happens. Can anyone kindle point me in the right direction cheers Luke- Hide quoted text - - Show quoted text -
[jQuery] Re: Accordion adventures
It seems that problem is caused by using easing function. When easeing property in animation method is set on linear, there's no jumping. On Aug 20, 8:29 pm, Dragan Krstic [EMAIL PROTECTED] wrote: Due to popular demand (Mikael ;) ) I decided to rewrite my invert accordion script into plug in. Original code is onhttp://www.bydot.net/hoveracc/ But, First incarnation of script (ver 0.0.1) shows old problem. Accordion is dancing. Demo can be found on:http://www.bydot.net/iccordion/ PS What you think about name iCcordion from Inverted Accordion, also i is connection to Apple as they inspired me to make it -- Dragan Krstić krdrhttp://krdr.ebloggy.com/
[jQuery] Re: Cycle Plugin Killing me
If you sort your indentation you could spot these things a lot easier! Try this: $(document).ready( function() { $('#birds').click( function() { $('#birds').cycle('fade'); } ); } ); Writing it all on one line just makes it a total swine to spot missing braces... On Aug 21, 6:37 am, Aaron Heimlich [EMAIL PROTECTED] wrote: Firebug sez: missing } after function bodyhttp://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Line 16 I think that code should be: $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); }); Instead of $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); On 8/21/07, Mitch [EMAIL PROTECTED] wrote: Im having a heck of a time getting the Cycle plugin to work. Cycle is athttp://www.malsup.com/jquery/cycle/and appears to be the best slide show out there. Here is my incredibly simple jQuery program: http://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Can anyone see what I have missed? Thanks Mitch -- Aaron Heimlich Web Developer [EMAIL PROTECTED]://aheimlich.freepgs.com
[jQuery] Loading remote JavaScript
Is there an easy way to get a remote script and run code when it has loaded as well as check the content type? $.getScript only works with those scripts on the same server. The problem I have is when using Google Maps I get often the sorry CAPTCHA page (the one you get if too many requests are made) instead of the JavaScript. This results in the rest of the JavaScript (not just the map) on the page not working. What I want to do is show that page (preferably in a Thickbox) when it happens so that the map will still work. The IP address is a common one (which is probably why the page is loaded) as it is used on a large WAN (NHS infact). I have asked on the Google Maps Help Group (July 31), but no one replied (even after replying to my own post over a week later. So I want to find out how to work around the problem. I have also tried having a proxy page at the server using ASP.NET and even then it doesn't work (only part of the script is loaded) which is a WebHandler: %@ WebHandler Language=C# Class=GoogleMaps % using System; using System.Web; using System.Text; using System.IO; using System.Net; public class GoogleMaps : IHttpHandler { public void ProcessRequest (HttpContext ctx) { ctx.Response.ContentType = text/javascript; ctx.Response.Write(GetRemoteScript(ctx, http://maps.google.com/maps? file=apiv=2key=GoogleMapsAPIKey)); ctx.Response.End(); } public bool IsReusable { get { return false; } } private string GetRemoteScript(HttpContext ctx, string url) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Referer = http://www.mywebsite.nhs.uk;; request.ContentType = text/javascript; try { // get the response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // set the content length int contentLength = (int)response.ContentLength; // get the stream Stream responseStream = response.GetResponseStream(); // Pipes the stream to a higher level stream reader with the required encoding format. StreamReader readStream = new StreamReader(responseStream, ctx.Response.ContentEncoding); // create a char array char[] data = new char[contentLength]; // load from the stream into the char array readStream.Read(data, 0, contentLength); // return the data as a string return new String(data); } catch(Exception ex) { return string.Empty; } return string.Empty; } }
[jQuery] Re: New Plugin: Live Query (previously called Behavior)
Awesome, Brandon! * Live Queries work with attribute and class selectors * Live Query automatically unbinds events to unmatched elements and when the Live Query is expired * Live Query can fire a second callback for when an element is unmatched and when the Live Query is expired
[jQuery] Re: Loading remote JavaScript
Hi, Is there an easy way to get a remote script and run code when it has loaded as well as check the content type? $.getScript only works with those scripts on the same server. You can use $('script src=http://example.com/myscript.js; type=text/javascript'). appendTo('head'); It should work in most cases, but there are Safari Versions which don't interpret scripts loaded that way. Christof
[jQuery] Re: Loading remote JavaScript
On Aug 21, 1:15 pm, Christof Donat [EMAIL PROTECTED] wrote: Hi, Is there an easy way to get a remote script and run code when it has loaded as well as check the content type? $.getScript only works with those scripts on the same server. You can use $('script src=http://example.com/myscript.js; type=text/javascript'). appendTo('head'); It should work in most cases, but there are Safari Versions which don't interpret scripts loaded that way. Christof I'm aware of that method, but I want a callback to find out what content type was loaded, display it if text/html or execute it if text/ javascript. Although the bit I am not sure of is how to execute the script after the user has passed the CAPTCHA test (especially since it is on a separate domain). Having a proxy on the server is the closest I can get, but I don't know why the whole script is not being retrieved.
[jQuery] [Plugin] jQuery Babelfish Plugin
Hey folks, Time for another plugin - http://digitalspaghetti.me.uk/index.php?q=jquery-babelfish This is my jQuery Babelfish plugin. It provides a very easy way for you to add translation services via Google Translate on your site. The default setting is from English to French, but it can be overridden to input and output any language that Google supports. Using the plugin, you can pass in text from any element, including the body. You can see the demo on the page above to see how this can be achieved. -- Tane Piper http://digitalspaghetti.me.uk This email is: [ x ] blogable [ ] ask first [ ] private
[jQuery] Jquery toggle headache
Hi people, I have this issue I could need some help with resolving. It's driving me crazy. Imagine an email inbox made up from an unordered list (ul) and all the list items that show the subject, date etc. Pretty basic stuff really (kinda like your hotmail or gmail inbox). Instead of going to the 'read message' page I want the message to appear on the same page, underneath the subject when the li or subject is clicked. The data is being fetched with a post, and the response is placed in a hidden list item that is made visible when the response is received. When the li or subject link is clicked again, the message is closed. Also, there's only one message that can be opened, so if there's a message open, and another subject is clicked, the open one closes and the new one is displayed. It's sort of working, but the toggle seems to be acting weird. Can someone please go over the code and tell me what I might be doing wrong? I have this so far: jQuery: function readmail (mail_code) { // Activate toggle on li $('#'+ mail_code).toggle(function(){ // first toggle part $.post(../../test/+ mail_code, { }, function(response){ // Hide the spinner $(#spinner-+ mail_code).fadeOut(500); // Populate the prepared p-element with the response $(#prep-+ mail_code).html(response).fadeIn(500); }); // Remove the 'new' highlight in case it's there // Add new class to indicate this is the one opened $('#'+ mail_code).removeClass('highlight bold highlight_active').addClass('highlight_active').filter(.highlight_active); },function(){ // next toggle part // Close the p-element $(#prep-+ mail_code).fadeOut(500); }); return false; }; The list (I've left the php intact): ul class=mailbox-list li ?php foreach($query as $row): ? ?php if ($row-mail_status == 0): ? li class=highlight bold id=?=$row-mail_code? ?php else : ? li id=?=$row-mail_code? target=?=$row-mail_code? ?php endif; ? p class=subjecta class=?=$row-mail_code? href=?=$row- mail_code? onfocus=javascript:readmail('?=$row-mail_code?')?= $row-mail_subject?/a/p p class=sender?=$row-user_name?/p p class=date?=strftime (%e %b, strtotime ($row- mail_date_sent))?/p p id=spinner-?=$row-mail_code? class=spinner style=display: none/p p class=clearer/p /li li id=prep-?=$row-mail_code? style=width: 480px; background: #ff; display: none; border-bottom: 3px solid #CC99FF /li ?php endforeach; ? /ul Am I thinking correct?
[jQuery] Javascript object detection
I'm writing some plugins/modules for JQuery and a PERL based CMS (yeah yeah, I know, PHP is simpler, etc, but its a long story, and I'm stuck with it), and I have a bit of a dilemma. I'm working on an implementation of JSON-RPC v1.1 using JQuery on the client side, and PERL on the server. I have the underlying preliminary code working - calls are being made, and responses generated and handled. I'm going back and doing the data validation and checking to make the system a little more robust. During the development, in the spec it says calls made using a GET can only be strings or arrays (which can be flattened into a string). Using $.ajax, I can see this happening happily. But I can also send it an object, which it translates in [object object]. So the question is, how do I check for the existance of type Object on a variable - and it may not necessarily be at the top level. i.e. Array with an Object in that array somewhere. I just want to check for the existance of this condition quickly, not correct it. Any ideas?
[jQuery] $('#id').Pulsate(500, 100) .stop ??
hello group, i use $('#id').Pulsate(500, 100); but i cannot found where i can stop my pulsate or how i can do this ? best regards hans
[jQuery] Passing variables to a dynamically loaded script
I am writing a page where I need to load different scripts based on what the user is allowed to do. I started by using $.getScript(test.js), which worked fine until I realized that I need a variable from the original page within the script I called. What I have ended up doing (and haven't tested beyond firefox2) is using a regular $.get and doing an eval() in the callback. This seems to allow me to use the variable I need within test.js, but it really seems that there should be a better way of doing this. Maybe it is just my dislike for eval() that makes me not like what I am using now. Any suggestions? //a dumbed down version of what I'm doing var pageId = 1234; $.get( test.js, function(data){ eval(data); });
[jQuery] Re: some javascript function on some.html won't work
Thanks for all you help I found the problem is use $.get Instead of .load and call the function on call back will wrok but base on we include .js on the top level html for example we have two html(1.html,2.html) and two .js(1.js,2.js) if we do thing on 1.html like following 1.html html head script src=1.js/script script src=2.js/script/head body div id=somediv/div /body if we use jquery to get 2.html to show on #somediv and call some function from 2.js use callback it work great but if we do thing as .html html head script src=1.js/script /head body div id=somediv/div /body /html 2.html html head script src=2.js/script /head body div id=somediv/div /body /html then try to get 2.html to show on #somediv and call some function from 2.jsuse callback it won't work !! this mean another problem ,we need to load a lot of .js on 1.html (like jquery.js plugin1.js plugin2.js plugin3.js my1.js, my2.js,.) and wait for using ,but user may be just need one or two , it cause 1.htmldifficult download ,any solution to solve this ? Thanks for your help Michael On 8/20/07, Wizzud [EMAIL PROTECTED] wrote: What does some.html look like? You imply that it can be run in its own right, ie that it is a full document. IF you are trying to inject a full document into the DOM under the 'somediv' DIV then it would not be surprising if some functionality failed. Michael Lo wrote: Dear all: can some one help why sometime i load some html like $(somediv).show(slow).load(some.html); some javascript function on some.html won't work but it will work when call it alone? Thanks!! Michael -- View this message in context: http://www.nabble.com/some-javascript-function-on-%22some.html%22-won%27t-work-tf4295619s15494.html#a12228822 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Square brackets in name-attribute
Thank your very much! Marc On 20 Aug., 17:00, Dan G. Switzer, II [EMAIL PROTECTED] wrote: Marc, a problem I couldn't find a solution for is the following: I have an input element with the attribute: input name=[DUS][1] / Getting this element is easy using: $('[EMAIL PROTECTED]') But what to do when I try to search for the following: $('[EMAIL PROTECTED]') You should be able to use: $([EMAIL PROTECTED]'[DUS][1]']) Also, be sure to read for more tips:http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_select_an_... _that_has_weird_characters_in_its_ID.3F -Dan
[jQuery] Re: simple menu - hover issue
Hvala Dragane! :) Milos. On Aug 20, 5:12 pm, Dragan Krstic [EMAIL PROTECTED] wrote: Your problem is quite usuall. Go to plugin page and download hoverIntent plugin. It will help you. Search trough list if you want to know more about this bug. And, welcome to the list! -- Dragan Krstić krdrhttp://krdr.ebloggy.com/
[jQuery] changing class
hi i'm trying to change the class of a label and i'm using this: $('label').click(function(){ $(this).toggleClass('pop').toggleClass('tart'); return false; }); initially the label class is set to 'pop'. when the label is clicked it toggles pop off and tart on, but then it runs a 2nd time and toggles it back to pop. why does the function run twice?
[jQuery] Re: [Plugin] jQuery Babelfish Plugin
Tane, That is a very good idea, Very! On 8/21/07, Tane Piper [EMAIL PROTECTED] wrote: Hey folks, Time for another plugin - http://digitalspaghetti.me.uk/index.php?q=jquery-babelfish This is my jQuery Babelfish plugin. It provides a very easy way for you to add translation services via Google Translate on your site. The default setting is from English to French, but it can be overridden to input and output any language that Google supports. Using the plugin, you can pass in text from any element, including the body. You can see the demo on the page above to see how this can be achieved. -- Tane Piper http://digitalspaghetti.me.uk This email is: [ x ] blogable [ ] ask first [ ] private -- Benjamin Sterling http://www.KenzoMedia.com http://www.KenzoHosting.com
[jQuery] Re: Loading remote JavaScript
Hi, I'm aware of that method, but I want a callback to find out what content type was loaded, display it if text/html or execute it if text/ javascript. $('script src=http://example.com/myscript.js; type=text/javascript'). appendTo('head'); $('script type=text/javascriptcallMyCallback/script'). appendTo('head'); Since the second tag will be inserted after the first, it will be executed after the first script is loaded and executed. Well, you don't get the content Type, but you can check for the existance of variables or functions that should be in the script. That at least tells you if the script has been loaded successfully as javascript. Christof
[jQuery] Re: .change() and IE bug
Well IE does ot support the bind on the divs, p's, etc... I did relize that i have access to the oringal documents dom when calling ajax in the ajax called file so i have it working in both FF and IE now, thanks for the, i will take a look at the plugin too. R. Rajesh Jeba Anbiah wrote: On Aug 20, 6:13 pm, Eridius [EMAIL PROTECTED] wrote: I have now just tried destination.load('/lib/ajax/price_buster.php', {'get': 'destination'}); destination.bind('change', function() { snip Add bind in load's callback, otherwise, you won't be having elements to bind. Or use LiveQuery plugin. -- ?php echo 'Just another PHP saint'; ? Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/ -- View this message in context: http://www.nabble.com/.change%28%29-and-IE-bug-tf4298714s15494.html#a12254542 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Javascript object detection
Hi, I may be wrong on understanding your question or need, but it sounds like something I came across as well and wrote a plug-in solution. Background: The bottom line is the jQuery AJAX calls (.get, .load, etc) will use an encoded url request and it issues ampersand () delimited key=value (or name=value) pairs. lets call them NV pairs. The final request is: url?parameters_in_nvpairs_format example /someprogram?p1=v1p2=v2 However, that is not what you pass for parameters for the optional .get(,parameter) variable. It only access an JSON formatted object or array. WRONG: -- .get(url, p1=v1p2=v2); RIGHT-- .get(url, {p1:v1, p2:v2})'; If you pass NVpairs, believe it or not, jQuery will see the strng as an array of characters and send a pair for each character in the string using the index of the string as the name or key: 0=p1=12=%3D3=v4=15=%266=p7=28=%3D9=v10=2 Solution: I found this non support for passing a natural stirng of nvpairs to be a obstrusive design so I created a override plug-in for the base method $.param() which handles this transformation. (function($) { var _inherit = $.param; if ($.fn.jquery $.fn.jquery = 1.1.3.1) { $.param = function(a) { return (a.constructor == String)?a:_inherit(a); }; } })(jQuery); This will allow you to send a string of nvpairs, an JSON object or array. Note, the (a.constructor == String) line.Maybe that is all you needed? To detect the type of variable? Not sure if this applies to you, but I hope it helps. -- HLS On Aug 21, 1:59 am, DocWyatt2001 [EMAIL PROTECTED] wrote: I'm writing some plugins/modules for JQuery and a PERL based CMS (yeah yeah, I know, PHP is simpler, etc, but its a long story, and I'm stuck with it), and I have a bit of a dilemma. I'm working on an implementation of JSON-RPC v1.1 using JQuery on the client side, and PERL on the server. I have the underlying preliminary code working - calls are being made, and responses generated and handled. I'm going back and doing the data validation and checking to make the system a little more robust. During the development, in the spec it says calls made using a GET can only be strings or arrays (which can be flattened into a string). Using $.ajax, I can see this happening happily. But I can also send it an object, which it translates in [object object]. So the question is, how do I check for the existance of type Object on a variable - and it may not necessarily be at the top level. i.e. Array with an Object in that array somewhere. I just want to check for the existance of this condition quickly, not correct it. Any ideas?
[jQuery] Re: Loading remote JavaScript
On Aug 21, 2:19 pm, Christof Donat [EMAIL PROTECTED] wrote: Hi, I'm aware of that method, but I want a callback to find out what content type was loaded, display it if text/html or execute it if text/ javascript. $('script src=http://example.com/myscript.js; type=text/javascript'). appendTo('head'); $('script type=text/javascriptcallMyCallback/script'). appendTo('head'); Since the second tag will be inserted after the first, it will be executed after the first script is loaded and executed. Well, you don't get the content Type, but you can check for the existance of variables or functions that should be in the script. That at least tells you if the script has been loaded successfully as javascript. Christof The content returned from Google is in HTML format when it thinks someone is abusing their system with too many requests. As a result, the browser tries to execute the HTML as JavaScript, but as it is HTML instead there is a runtime error (thus preventing any further scripts from running). Unfortunately, this is not that easy to duplicate (unless you happen to be on the NHS network or some other large WAN) - at this very moment it is working, but I never know when it is going to fall over again. I don't know if the issue is localised or WAN-wide. There is an NHS site that uses Google Maps already: http://www.qof.ic.nhs.uk (not powered by jQuery though) and the main NHS.UK site uses Virtual Earth, but there are no plugins for working with that.
[jQuery] Re: What to do when a plugin's css gets in your way
On Aug 20, 2007, at 11:59 PM, Mitch wrote: I felt Karl's cluetip popups on his demo seemed slow to respond to me, and I did not like that I had to add another plugin to use them (dimensions). On the other hand Karl does a great job on documenting his work and is incredibly helpful soUnless I someone bails me out I will have to switch. Hi Mitch, The slowness of the clueTips in the demo might have to do with the general suckiness of the server it's on. You might want to try placing the plugin and demo files on your own server and testing there to see how general the problem is. Who knows, though -- maybe all of the positioning calculations are slowing it down, too. I understand the concern about overloading your pages with multiple .js includes. Dimensions, though, is such a spectacular plugin for getting/setting position that I just didn't feel I could do without it. Anyway, its inclusion might be one of the reasons that the clueTip doesn't suffer from the same variable positioning problems you're experiencing with the jTip plugin in IE7. Also, a lot of other plugins depend on Dimensions, too, so you might find yourself having to use it anyway. By the way, I just released a new version of clueTip ( 0.8.5 ) at http://jquery.com/plugins/project/cluetip/ so if you do decide to use it (no pressure ;-) ), grab that one. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com
[jQuery] Re: Passing variables to a dynamically loaded script
I'm not seeing the picture of your application design requirements, but is using session cookies out of the questions to memorize the page ids? Yes, depending on eval() can bite you. Most of our user access stuff is server driven to customize user pages. It takes away any security loophole if its driven by the client. Probably better if you can make this part of it server driven. -- HLS On Aug 21, 8:15 am, Christopher [EMAIL PROTECTED] wrote: I am writing a page where I need to load different scripts based on what the user is allowed to do. I started by using $.getScript(test.js), which worked fine until I realized that I need a variable from the original page within the script I called. What I have ended up doing (and haven't tested beyond firefox2) is using a regular $.get and doing an eval() in the callback. This seems to allow me to use the variable I need within test.js, but it really seems that there should be a better way of doing this. Maybe it is just my dislike for eval() that makes me not like what I am using now. Any suggestions? //a dumbed down version of what I'm doing var pageId = 1234; $.get( test.js, function(data){ eval(data); });
[jQuery] Re: Javascript object detection
Important clarification needs to be made here: Solution: I found this non support for passing a natural stirng of nvpairs to be a obstrusive design so I created a override plug-in for the base method $.param() which handles this transformation. (function($) { var _inherit = $.param; if ($.fn.jquery $.fn.jquery = 1.1.3.1) { $.param = function(a) { return (a.constructor == String)?a:_inherit(a); }; } })(jQuery); This will allow you to send a string of nvpairs, an JSON object or array. I mean to say: This will allow you to PASS a string of nvpairs, an JSON object or array for the jQuery .get, .load methods. jQuery, per HTTP standard, will always send nvpairs unless you specifically use a POST with an encoding type such as multipart/form-data which will send data in a different boundary block separated layout. -- HLS
[jQuery] Re: Passing variables to a dynamically loaded script
On Aug 21, 2:15 pm, Christopher [EMAIL PROTECTED] wrote: What I have ended up doing (and haven't tested beyond firefox2) is using a regular $.get and doing an eval() in the callback. This seems to allow me to use the variable I need within test.js, but it really seems that there should be a better way of doing this. Maybe it is just my dislike for eval() that makes me not like what I am using now. Any suggestions? i just wrote a long write-up for you on how to do this but Firefox crashed and i lost it... so here's a summary. You can't send vars directly to JS, unfortunately, but one way to simulate this is to use a PHP (or other server-side) filter: $.get('myScript.php', {foo:'bar'}); // this will return JS code, not PHP code myScript.js: ... foo = REPLACEMENT_FOO; ... myScript.php: $txt = file_get_contents('myScript.js'); $txt = preg_replace( '/\bREPLACEMENT_FOO\b/', $_GET['foo'], $txt ); echo $txt; Obviously, you need to do error handling and checking $_GET['foo'] and such, but you get the general idea. If you need help understanding preg_replace(), i recommend googling for perl compatible regular expressions, as there is TONS of information available on them out there. :)
[jQuery] Re: Cycle Plugin Killing me
I got it to work, thank you guys, as you can see here (wait a few seconds for the fade to occur). http://www.whatbird.com/wwwroot/Components/cycle%20demo.html However I cant get the special effects to work. For example this link, which uses $('#birds').cycle( {fx: 'scrollDown'} ); should do a scroll down: http://www.whatbird.com/wwwroot/Components/cycle%20demo2.html Instead nothing happens. And Firebug says there are no style rules, but the rules are there as you can see. Thanks for your help On Aug 20, 10:37 pm, Aaron Heimlich [EMAIL PROTECTED] wrote: Firebug sez: missing } after function bodyhttp://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Line 16 I think that code should be: $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); }); Instead of $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); On 8/21/07, Mitch [EMAIL PROTECTED] wrote: Im having a heck of a time getting the Cycle plugin to work. Cycle is athttp://www.malsup.com/jquery/cycle/and appears to be the best slide show out there. Here is my incredibly simple jQuery program: http://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Can anyone see what I have missed? Thanks Mitch -- Aaron Heimlich Web Developer [EMAIL PROTECTED]://aheimlich.freepgs.com- Hide quoted text - - Show quoted text -
[jQuery] Re: Cycle Plugin Killing me
Im going to do this from now on, its a really good idea. I wish there was some kind of program that could scan the jQuery and correct braces or at least tell you where they are wrong. On Aug 21, 3:17 am, [EMAIL PROTECTED] wrote: If you sort your indentation you could spot these things a lot easier! Try this: $(document).ready( function() { $('#birds').click( function() { $('#birds').cycle('fade'); } ); } ); Writing it all on one line just makes it a total swine to spot missing braces... On Aug 21, 6:37 am, Aaron Heimlich [EMAIL PROTECTED] wrote: Firebug sez: missing } after function bodyhttp://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Line 16 I think that code should be: $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); }); Instead of $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); On 8/21/07, Mitch [EMAIL PROTECTED] wrote: Im having a heck of a time getting the Cycle plugin to work. Cycle is athttp://www.malsup.com/jquery/cycle/andappears to be the best slide show out there. Here is my incredibly simple jQuery program: http://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Can anyone see what I have missed? Thanks Mitch -- Aaron Heimlich Web Developer [EMAIL PROTECTED]://aheimlich.freepgs.com- Hide quoted text - - Show quoted text -
[jQuery] Re: Cycle Plugin Killing me
Mitch, Firebug picked up the missing bracket as soon as I loaded the original page. Are you running FF with Firebug? If not, its definitely a lifesaver. Rey Mitch wrote: Im going to do this from now on, its a really good idea. I wish there was some kind of program that could scan the jQuery and correct braces or at least tell you where they are wrong. On Aug 21, 3:17 am, [EMAIL PROTECTED] wrote: If you sort your indentation you could spot these things a lot easier! Try this: $(document).ready( function() { $('#birds').click( function() { $('#birds').cycle('fade'); } ); } ); Writing it all on one line just makes it a total swine to spot missing braces... On Aug 21, 6:37 am, Aaron Heimlich [EMAIL PROTECTED] wrote: Firebug sez: missing } after function bodyhttp://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Line 16 I think that code should be: $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); }); Instead of $(document).ready(function(){$('#birds').click(function() { $('#birds').cycle('fade'); }); On 8/21/07, Mitch [EMAIL PROTECTED] wrote: Im having a heck of a time getting the Cycle plugin to work. Cycle is athttp://www.malsup.com/jquery/cycle/andappears to be the best slide show out there. Here is my incredibly simple jQuery program: http://www.whatbird.com/wwwroot/Components/Cycle%20Demo.html Can anyone see what I have missed? Thanks Mitch -- Aaron Heimlich Web Developer [EMAIL PROTECTED]://aheimlich.freepgs.com- Hide quoted text - - Show quoted text -
[jQuery] Re: Cycle Plugin Killing me
On Aug 21, 4:14 pm, Mitch [EMAIL PROTECTED] wrote: Im going to do this from now on, its a really good idea. I wish there was some kind of program that could scan the jQuery and correct braces or at least tell you where they are wrong. Almost every modern text editor can do this for you. To name just a small number of them: xemacs emacs vi vim kate kwrite ... there are certainly some for Windows which can do this, too. (Xemacs runs on Windows but has a pretty high learning curve.)
[jQuery] Re: $('#id').Pulsate(500, 100) .stop ??
On Aug 21, 9:58 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: i use $('#id').Pulsate(500, 100); but i cannot found where i can stop my pulsate or how i can do this ? The docs: http://interface.eyecon.ro/docs/fx say that the arguments are (duration,times), which means that your pulsing will stop after it has run 100 times (of 500ms each, or after a total of 50 seconds). These docs: http://interface.eyecon.ro/docs/animate detail a stop() method which might or might be able to stop the animation prematurely.
[jQuery] Re: Jquery toggle headache
On Aug 20, 4:50 pm, Codex [EMAIL PROTECTED] wrote: It's sort of working, but the toggle seems to be acting weird. Can someone please go over the code and tell me what I might be doing wrong? A quick scan appears to be logical. What's wrong? Describe Acting Wierd. By not being specific, it forces people who may be interested in helping to actually spent more time to prepare a test bed to see what you see as wield. A good development tip as well as tip when seeking public help: Try to reduce your code to a plain vanilla example where there are no other dependencies, thus using divide and conquer techniques by separating the functional parts. You reduce the amount of people who can help when posting highly specific code. You never know. You might even find the problem by dividing and conquering each part. I know it does for me, atleast 99% of the time. :-) -- HLS
[jQuery] Re: changing class
fixed: $(this).toggleClass('pop').toggleClass('tart').ajaxStop(function(){}); On Aug 21, 12:58 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi i'm trying to change the class of a label and i'm using this: $('label').click(function(){ $(this).toggleClass('pop').toggleClass('tart'); return false; }); initially the label class is set to 'pop'. when the label is clicked it toggles pop off and tart on, but then it runs a 2nd time and toggles it back to pop. why does the function run twice?
[jQuery] Dinamically add elements to a existing jCarouselLite
Hi jQuery folks, i'm trying to create a page where a new li element is to be added to an existing carousel. The new element's content is coming from some ajax call and it should fit dinamically into the existing carousel forcing it to reinitialize (i suppose). Ex. THIS IS THE HTML MARKUP OF THE ORIGINAL CAROUSEL div id=carousel ul id=carouselList lihtml markup content/li /ul /div --JCAROUSELLITE JAVASCRIPT INIT CODE $(#carousel).jCarouselLite({ btnGo: new Array(#historyGo1), visible:1, circular:false }); --- suppose that on completion of aN ajax request we get some other html code, then we should be supposed to add it to a new li element appended to the ul this way: $(ul#carouselList).append(li+new html code from ajax+/li); - Now i suppose that i should reinitialize the carousel but it doesent seem to work that way! Since i'm getting lots of troubles doing that, i would greatly appreciate if anyone can point me to some hints or existing documentation... Thanks in advance! thorfinn
[jQuery] Re: Cycle Plugin Killing me
Mitch, I've just fixed a bug in the scroll transitions. v1.8 is available now and should fix the problem. Give me a shout if you're still having troubles. http://www.malsup.com/jquery/cycle/download.html Mike I got it to work, thank you guys, as you can see here (wait a few seconds for the fade to occur). http://www.whatbird.com/wwwroot/Components/cycle%20demo.html However I cant get the special effects to work. For example this link, which uses $('#birds').cycle( {fx: 'scrollDown'} ); should do a scroll down: http://www.whatbird.com/wwwroot/Components/cycle%20demo2.html Instead nothing happens.
[jQuery] Re: add class to row object of table
2007/8/21, Potluri [EMAIL PROTECTED]: Hi, My table format is this table id=srTable tbody trtdsome data/td/tr trtdsome data/td/tr trtdsome data/td/tr trtdsome data/td/tr /tbody /table I have a small issue which might be easy for jquery pros. Initially I'm saving up all the table rows as suggested by George(Thanks to him) in my previous post like. for( var i = 0, n = trows.length; i n; ++i ) { var row = trows[i]; var col = row.firstChild; rows.push({ row:row, col:col, style:row.style, visible:true }); } like nRows=rows.length; for( var i = 0; i nRows; ++i ) { var row = rows[i], col = row.col; $(row).addClass(bold); } The problem is later when I'm trying to add or remove class in jquery fashion like $(row).addClass(bg_litegray) its giving some error. I think I'm doing it wrong. Can anyone of you suggest me how to use this row similar to $(#srTable tbody tr) in jquery so that I can add class, remove class, apply filter like $(row).filter('[EMAIL PROTECTED]refine]')etc... Thanks in advance. -- View this message in context: http://www.nabble.com/add-class-to-row-object-of-table-tf4301879s15494.html#a12245004 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: New Plugin: Live Query (previously called Behavior)
Oh, this is DOPE dude!! This is destined to be integrated into jQuery; this is a real problem for dynamic web pages right now. THANKS!!! Sean Brandon Aaron wrote: Some of you may be familiar with Behavior. It was a first attempt at implementing a live DOM experience. Behavior has been rewritten from the ground up with performance in mind and new features. It is now called Live Query. A couple of new features are that: * Live Queries work with attribute and class selectors * Live Query automatically unbinds events to unmatched elements and when the Live Query is expired * Live Query can fire a second callback for when an element is unmatched and when the Live Query is expired Check out the blog post for more details: http://blog.brandonaaron.net/2007/08/19/new-plugin-live-query/ -- Brandon Aaron -- View this message in context: http://www.nabble.com/New-Plugin%3A-Live-Query-%28previously-called-Behavior%29-tf4296594s15494.html#a12256798 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Fwd: jQuery and UTF8
On Aug 21, 8:11 pm, barophobia [EMAIL PROTECTED] wrote: On 8/21/07, R. Rajesh Jeba Anbiah [EMAIL PROTECTED] wrote: snip 2. or send the UTF-8 charset header via header(); browser should handle All the UTF-8 data is stored in a database. Regarding #2. I put header('Content-type: text/html; charset=UTF-8'); right before the output of my file and Firebug now shows the correct content-type... but it still shows question marks. I had work with lot of UTF-8 and had no problem: 1. You don't have font? 2. or Your current charset is different from one that is been loaded? 3. or Do you have any link for me to check? -- ?php echo 'Just another PHP saint'; ? Email: rrjanbiah-at-Y!comBlog: http://rajeshanbiah.blogspot.com/
[jQuery] Re: Jquery toggle headache
Codex, I played with your code and this is what I found: Yes, It acted wierd! g First, I think that was because of the onFocus= on the a tag link which will fool with your mind depending on where is the current keyboard focus including switching browser pages. :-). Changing it to OnClick= begins to bring sanity to getting it worked out. Second, the toggle was being acted on the #mail_code id rather than the #prep-mail_code. If that is some cool trick you were thinking of, it certainly confused the hell out of mail Anyway, after that I changed you readmail() function to: function readmail (mail_code) { var $p = $('#prep-'+ mail_code); if ($p.is(:hidden)) { // Its hidden so toggled it on and do a AJAX call $p.toggle(); $.post(/jquery-fake-mail.wct, {}, function(response){ // Hide the spinner $(#spinner-+ mail_code).fadeOut(500); // Populate the prepared p-element with the response $(#prep-+ mail_code).html(response).fadeIn(500); } ); } else { // Its showing so slowly fade away and hide it $(#prep-+ mail_code).fadeOut(500); } return false; }; it was a thing of beauty! g Note, the .post() command. I have my fake url there so I can dump text for this testing . Put back your URL there and it should work. Finally, if you really wanted the onfocus, you can now better begin to explore that to auto-turn off stuff. But I would pay attention to window switching issues there. :-) -- HLS On Aug 21, 10:13 am, Pops [EMAIL PROTECTED] wrote: On Aug 20, 4:50 pm, Codex [EMAIL PROTECTED] wrote: It's sort of working, but the toggle seems to be acting weird. Can someone please go over the code and tell me what I might be doing wrong? A quick scan appears to be logical. What's wrong? Describe Acting Wierd. By not being specific, it forces people who may be interested in helping to actually spent more time to prepare a test bed to see what you see as wield. A good development tip as well as tip when seeking public help: Try to reduce your code to a plain vanilla example where there are no other dependencies, thus using divide and conquer techniques by separating the functional parts. You reduce the amount of people who can help when posting highly specific code. You never know. You might even find the problem by dividing and conquering each part. I know it does for me, atleast 99% of the time. :-) -- HLS
[jQuery] Iterating over 1000 items - optimizing jquery
Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Fwd: jQuery and UTF8
On 8/21/07, R. Rajesh Jeba Anbiah [EMAIL PROTECTED] wrote: I had work with lot of UTF-8 and had no problem: 1. You don't have font? 2. or Your current charset is different from one that is been loaded? 3. or Do you have any link for me to check? 1. I do have the font. It appears correctly when not being loaded through AJAX. 2. UTF-8 is the charset of the data. 3. Thanks for trying to help me with this but unfortunately I don't have a link I can provide. I'll just have to do some more experiments when I get home. I'm pretty certain the answer is going to be rather simple and I'm just overlooking it right now. Chris.
[jQuery] Re: New Plugin: Live Query (previously called Behavior)
This should be intergrated in the core jquery, i think it could replace .bind since it does the same thing but more without have to change any parameters, just to to the change c.bind to .livequery. duma wrote: Oh, this is DOPE dude!! This is destined to be integrated into jQuery; this is a real problem for dynamic web pages right now. THANKS!!! Sean Brandon Aaron wrote: Some of you may be familiar with Behavior. It was a first attempt at implementing a live DOM experience. Behavior has been rewritten from the ground up with performance in mind and new features. It is now called Live Query. A couple of new features are that: * Live Queries work with attribute and class selectors * Live Query automatically unbinds events to unmatched elements and when the Live Query is expired * Live Query can fire a second callback for when an element is unmatched and when the Live Query is expired Check out the blog post for more details: http://blog.brandonaaron.net/2007/08/19/new-plugin-live-query/ -- Brandon Aaron -- View this message in context: http://www.nabble.com/New-Plugin%3A-Live-Query-%28previously-called-Behavior%29-tf4296594s15494.html#a12258261 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: New Plugin: Live Query (previously called Behavior)
What happens though if you want to REMOVE the binding from an object. Using this plugin, it would Rebind it right afterwards. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Eridius Sent: Tuesday, August 21, 2007 11:30 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: New Plugin: Live Query (previously called Behavior) This should be intergrated in the core jquery, i think it could replace .bind since it does the same thing but more without have to change any parameters, just to to the change c.bind to .livequery. duma wrote: Oh, this is DOPE dude!! This is destined to be integrated into jQuery; this is a real problem for dynamic web pages right now. THANKS!!! Sean Brandon Aaron wrote: Some of you may be familiar with Behavior. It was a first attempt at implementing a live DOM experience. Behavior has been rewritten from the ground up with performance in mind and new features. It is now called Live Query. A couple of new features are that: * Live Queries work with attribute and class selectors * Live Query automatically unbinds events to unmatched elements and when the Live Query is expired * Live Query can fire a second callback for when an element is unmatched and when the Live Query is expired Check out the blog post for more details: http://blog.brandonaaron.net/2007/08/19/new-plugin-live-query/ -- Brandon Aaron -- View this message in context: http://www.nabble.com/New-Plugin%3A-Live-Query-%28previously-called-Behavior %29-tf4296594s15494.html#a12258261 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Hi, I've improved my own function - to this: $(document).ready(function() { addPlusMinus([EMAIL PROTECTED]@type=text]); addPlusMinus([EMAIL PROTECTED]@type=text]); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); $(this).siblings(img.decrement).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); $(this).siblings(img.increment).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); }); } See it here: http://test2.danieleastwell.co.uk/test3/master_order_test.html It still takes about ten seconds to load. Any ideas how I could slim down this code? Thanks, Dan. On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Iterating over 1000 items - optimizing jquery
You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- View this message in context: http://www.nabble.com/Iterating-over-1000-items---optimizing-jquery-tf4306183s15494.html#a12258350 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Cycle Plugin Killing me
On 8/21/07, Stephan Beal [EMAIL PROTECTED] wrote: Almost every modern text editor can do this for you. To name just a small number of them: xemacs emacs vi vim kate kwrite ... there are certainly some for Windows which can do this, too. (Xemacs runs on Windows but has a pretty high learning curve.) For Windows, ultraedit is a very good choice (and it's been my favorite for years). Just another fyi :) Cheers,
[jQuery] Re: Problems with VALIDATE PLUGIN
I´m so sorry!!! On 8/20/07, Jörn Zaefferer [EMAIL PROTECTED] wrote: Jean schrieb: The error is in 795 line jQuery(element).data is not a function [Break on this error] : jQuery(element).data(); Please check Dependencies section of the plugin page. The - not so helpful - error indicates that the metadata plugin is missing. Gonna rename that method... http://bassistance.de/jquery-plugins/jquery-plugin-validation/#dependencies -- Jörn -- []´s Jean www.suissa.info Ethereal Agency www.etherealagency.com
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Thanks Corey, I've now got my code down to what follows. If I swap qty_field for input_text in the function bound to the image button's click event, obviously, any click increments all input values. Is there any way cutting this code down further? Thanks, Dan. $(document).ready(function() { addPlusMinus([EMAIL PROTECTED]@type=text]); addPlusMinus([EMAIL PROTECTED]@type=text]); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); $(input_text).siblings(img.decrement).bind(click, function() { qty_field = $(this).siblings([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); $(input_text).siblings(img.increment).bind(click, function() { qty_field = $(this).siblings([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } On 8/21/07, seedy [EMAIL PROTECTED] wrote: You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- View this message in context: http://www.nabble.com/Iterating-over-1000-items---optimizing-jquery-tf4306183s15494.html#a12258350 Sent from the JQuery mailing list archive at Nabble.com. -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Iterating over 1000 items - optimizing jquery
This can be reduced to this: $(document).ready(function() { function doPlusMinus(event) { qty_field = $(this).parent('td').find('[EMAIL PROTECTED]'); var num = $(qty_field).val(); $(qty_field).val( num + (event.data === true ? 1 : (num 0 ? -1 : 0)) ); } // Find our input fields, append a minus plus image (create minus image, add plus image after minus image) $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after( $('img src=images/buttons/button_minus.gif alt=- class=decrement /') .bind('click', false, doPlusMinus) .after( $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ); $(table.summarytable tr:even).addClass(odd); }); Cheers, -js On 8/21/07, seedy [EMAIL PROTECTED] wrote: You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- View this message in context: http://www.nabble.com/Iterating-over-1000-items---optimizing-jquery-tf4306183s15494.html#a12258350 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Fantastic, thanks Jonathon! One problem - only the minus appears - does the first after call need to be closed before the second? Thanks, Dan. On 8/21/07, Jonathan Sharp [EMAIL PROTECTED] wrote: This can be reduced to this: $(document).ready(function() { function doPlusMinus(event) { qty_field = $(this).parent('td').find('[EMAIL PROTECTED]'); var num = $(qty_field).val(); $(qty_field).val( num + ( event.data === true ? 1 : (num 0 ? -1 : 0)) ); } // Find our input fields, append a minus plus image (create minus image, add plus image after minus image) $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after( $('img src=images/buttons/button_minus.gif alt=- class=decrement /') .bind('click', false, doPlusMinus) .after( $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ); $(table.summarytable tr:even).addClass(odd); }); Cheers, -js On 8/21/07, seedy [EMAIL PROTECTED] wrote: You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- View this message in context: http://www.nabble.com/Iterating-over-1000-items---optimizing-jquery-tf4306183s15494.html#a12258350 Sent from the JQuery mailing list archive at Nabble.com. -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Setting the selected option in Safari 3
Hi; Based on this conversation: http://tinyurl.com/2qwpna I've added this code to my page function updateColor() { var currentColor = $(#setColorKey).val(); $(#color_Key option).each(function() { // $(this) is the current option element var thisValue = $(this).val(); if (thisValue == currentColor){ $(this).attr(selected, true); //safari logging. if(window.console) {window.console.log($(this).attr(selected)+ +thisValue);} return false; } }); } I'm testing on a Mac now, moving to Windows next. The problem is, on Safari 3. the option doesn't get selected. It works fine in Firefox/Camino. The Safari javascript console shows the log entry, but doesn't update the select. Can anyone offer any insight? Thanks, in advance.
[jQuery] Re: New Plugin: Live Query (previously called Behavior)
The beautiful of jQuery is the extensibility of the plugins. The core of jQuery must be small, with the core methods and without complexes methods that overload the processor. In this sense, livequery is very good, I like it, but why insert it into the core? If you want allways the livequery behaviour, you simply concatenate it to the jQuery file ;-) jQuery event methods uses the JavaScript core function addEventListener or attachEvent (in IE) so the execution of these methods is fast. But you can check the code of Livequery, it checks allways the new elements attaching the event, and sets an interval loop for checking again and again. I have many projects that I don't need the Livequery behaviour and with the jQuery core functions works well, so I don't need overload my code using Livequery in these projects. Maybe, in some moments you can find plugins very cool, but it is not good insert all the pieces of code that you like into the jQuery code. Making the custom jQuery file to me (example): java -jar custom_rhino.jar -w -version 150 -f jquery.js -c jquery.wordscounter.js -c jquery.copyEvent.js jquery.plugins.js So I simply attach jquery.plugins.js in my code and I can use all the methods. Another method (using php) HTML: script type=text/javascript src=js/getlibraries.php?js[]=jquery.jsjs[]=jquery.copyEvents.js. PHP: ? //compressing with gzip |ob_start(ob_gzhandler); |$all_code = ; for($i=0;$i count($_GET[js]); $i++){ $all_code .= file_get_contents($_GET[js][$i]); } echo $all_code; |ob_flush();| ? Eridius escribió: This should be intergrated in the core jquery, i think it could replace .bind since it does the same thing but more without have to change any parameters, just to to the change c.bind to .livequery. duma wrote: -- Best Regards, José Francisco Rives Lirola sevir1ATgmail.com SeViR CW · Computer Design http://www.sevir.org Murcia - Spain
[jQuery] Re: Iterating over 1000 items - optimizing jquery
You do a lot of repetitive selecting. Something like this might help (untested): $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } }) .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); $qty_field.val($qty_field.val()+1); }); $(table.summarytable tr:even).addClass(odd); I removed the increment/decrement classes from the images to make the code more readable and because I'm not using them for selection anymore. If you need them there for styling or something, just add them back. Also, here's another version that may or may not be faster: $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .each(function() { var $qty_field = $(this); $qty_field.siblings('img').bind('click', function() { if(this.alt == '+') { $qty_field.val($qty_field.val()+1); } else if(this.alt == '-') { if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } } }); }); $(table.summarytable tr:even).addClass(odd); Good luck with it. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Iterating over 1000 items - optimizing jquery
heh, I took so long writing my reply, a bunch of other people replied in the mean time. Anyways, I suggest you use firebug (console.time/console.timeEnd) to see how long each version takes. --Erik On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: You do a lot of repetitive selecting. Something like this might help (untested): $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } }) .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); $qty_field.val($qty_field.val()+1); }); $(table.summarytable tr:even).addClass(odd); I removed the increment/decrement classes from the images to make the code more readable and because I'm not using them for selection anymore. If you need them there for styling or something, just add them back. Also, here's another version that may or may not be faster: $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .each(function() { var $qty_field = $(this); $qty_field.siblings('img').bind('click', function() { if(this.alt == '+') { $qty_field.val($qty_field.val()+1); } else if(this.alt == '-') { if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } } }); }); $(table.summarytable tr:even).addClass(odd); Good luck with it. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Yes, it looks like he intends to close the first 'after' before starting the second. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Fantastic, thanks Jonathon! One problem - only the minus appears - does the first after call need to be closed before the second? Thanks, Dan. On 8/21/07, Jonathan Sharp [EMAIL PROTECTED] wrote: This can be reduced to this: $(document).ready(function() { function doPlusMinus(event) { qty_field = $(this).parent('td').find('[EMAIL PROTECTED]'); var num = $(qty_field).val(); $(qty_field).val( num + ( event.data === true ? 1 : (num 0 ? -1 : 0)) ); } // Find our input fields, append a minus plus image (create minus image, add plus image after minus image) $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after( $('img src=images/buttons/button_minus.gif alt=- class=decrement /') .bind('click', false, doPlusMinus) .after( $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ); $(table.summarytable tr:even).addClass(odd); }); Cheers, -js On 8/21/07, seedy [EMAIL PROTECTED] wrote: You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- View this message in context: http://www.nabble.com/Iterating-over-1000-items---optimizing-jquery-tf4306183s15494.html#a12258350 Sent from the JQuery mailing list archive at Nabble.com. -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Iterating over 1000 items - optimizing jquery
No, not at all, many thanks to both - I still don't think it's beaten, but I'll have another look with what you and Jonathon's examples have given me (by example) in my understanding of chaining jquery. Jonathon's is very elegant, but needs some debugging to get it to work - I think I need to work through yours though, to cut the timing down, as it's still taking a while. If you have any further thoughts, though let me know... Thanks, Dan. On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: heh, I took so long writing my reply, a bunch of other people replied in the mean time. Anyways, I suggest you use firebug (console.time/console.timeEnd) to see how long each version takes. --Erik On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: You do a lot of repetitive selecting. Something like this might help (untested): $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } }) .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); $qty_field.val($qty_field.val()+1); }); $(table.summarytable tr:even).addClass(odd); I removed the increment/decrement classes from the images to make the code more readable and because I'm not using them for selection anymore. If you need them there for styling or something, just add them back. Also, here's another version that may or may not be faster: $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .each(function() { var $qty_field = $(this); $qty_field.siblings('img').bind('click', function() { if(this.alt == '+') { $qty_field.val($qty_field.val()+1); } else if(this.alt == '-') { if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } } }); }); $(table.summarytable tr:even).addClass(odd); Good luck with it. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog:
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Oh, one more thing, $qty_field.val($qty_field.val()-1); Is concatenating as a string, not adding! Just a small point, and nothing compared to the errors I'd make in coding without any testing!! Cheers, Dan. On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: No, not at all, many thanks to both - I still don't think it's beaten, but I'll have another look with what you and Jonathon's examples have given me (by example) in my understanding of chaining jquery. Jonathon's is very elegant, but needs some debugging to get it to work - I think I need to work through yours though, to cut the timing down, as it's still taking a while. If you have any further thoughts, though let me know... Thanks, Dan. On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: heh, I took so long writing my reply, a bunch of other people replied in the mean time. Anyways, I suggest you use firebug (console.time/console.timeEnd) to see how long each version takes. --Erik On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: You do a lot of repetitive selecting. Something like this might help (untested): $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } }) .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); $qty_field.val($qty_field.val()+1); }); $(table.summarytable tr:even).addClass(odd); I removed the increment/decrement classes from the images to make the code more readable and because I'm not using them for selection anymore. If you need them there for styling or something, just add them back. Also, here's another version that may or may not be faster: $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .each(function() { var $qty_field = $(this); $qty_field.siblings('img').bind('click', function() { if(this.alt == '+') { $qty_field.val($qty_field.val()+1); } else if(this.alt == '-') { if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } } }); }); $(table.summarytable tr:even).addClass(odd); Good luck with it. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 )
[jQuery] Re: Iterating over 1000 items - optimizing jquery
hmm, seems like your original version should have that problem too. Maybe the increment and decrement operators take care of the conversion. At any rate, should be: $qty_field.val(parseInt($qty_field.val())-1); And: $qty_field.val(parseInt($qty_field.val())+1); --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Oh, one more thing, $qty_field.val($qty_field.val()-1); Is concatenating as a string, not adding! Just a small point, and nothing compared to the errors I'd make in coding without any testing!! Cheers, Dan. On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: No, not at all, many thanks to both - I still don't think it's beaten, but I'll have another look with what you and Jonathon's examples have given me (by example) in my understanding of chaining jquery. Jonathon's is very elegant, but needs some debugging to get it to work - I think I need to work through yours though, to cut the timing down, as it's still taking a while. If you have any further thoughts, though let me know... Thanks, Dan. On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: heh, I took so long writing my reply, a bunch of other people replied in the mean time. Anyways, I suggest you use firebug (console.time /console.timeEnd) to see how long each version takes. --Erik On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: You do a lot of repetitive selecting. Something like this might help (untested): $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } }) .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); $qty_field.val($qty_field.val()+1); }); $(table.summarytable tr:even).addClass(odd); I removed the increment/decrement classes from the images to make the code more readable and because I'm not using them for selection anymore. If you need them there for styling or something, just add them back. Also, here's another version that may or may not be faster: $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .each(function() { var $qty_field = $(this); $qty_field.siblings('img').bind('click', function() { if(this.alt == '+') { $qty_field.val($qty_field.val()+1); } else if(this.alt == '-') { if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } } }); }); $(table.summarytable tr:even).addClass(odd); Good luck with it. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /); }); } function increment(image_button) { $(image_button).bind(click, function() {
[jQuery] Re: New Plugin: Live Query (previously called Behavior)
Andy, That is not entirely true. It only binds the event the first time it finds the element. If you called unbind on a particular element, the event would be unbound. The only time that event would be rebound is if the Live Query was expired (.expire()) and then re-setup (.livequery()). However I wouldn't rely on that functionality simply because that unbinding the event for one element in a collection means that you need to think about constructing a different selector. BTW ... calling .expire() would unbind all the events and ... if you where using a class selector like this: $('.doSomething').livequery('click', doSomething); Then you changed one of the elements by removing the class doSomething, the event would be unbound. -- Brandon Aaron On 8/21/07, Andy Matthews [EMAIL PROTECTED] wrote: What happens though if you want to REMOVE the binding from an object. Using this plugin, it would Rebind it right afterwards. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Eridius Sent: Tuesday, August 21, 2007 11:30 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: New Plugin: Live Query (previously called Behavior) This should be intergrated in the core jquery, i think it could replace .bind since it does the same thing but more without have to change any parameters, just to to the change c.bind to .livequery. duma wrote: Oh, this is DOPE dude!! This is destined to be integrated into jQuery; this is a real problem for dynamic web pages right now. THANKS!!! Sean Brandon Aaron wrote: Some of you may be familiar with Behavior. It was a first attempt at implementing a live DOM experience. Behavior has been rewritten from the ground up with performance in mind and new features. It is now called Live Query. A couple of new features are that: * Live Queries work with attribute and class selectors * Live Query automatically unbinds events to unmatched elements and when the Live Query is expired * Live Query can fire a second callback for when an element is unmatched and when the Live Query is expired Check out the blog post for more details: http://blog.brandonaaron.net/2007/08/19/new-plugin-live-query/ -- Brandon Aaron -- View this message in context: http://www.nabble.com/New-Plugin%3A-Live-Query-%28previously-called-Behavior %29-tf4296594s15494.html#a12258261 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Iterating over 1000 items - optimizing jquery
I think the problem with Jonathon's solution is that the added html can't have a click event bound to it? I'm not sure. I've tried stripping that code down, so that the bind click is just alerting, but that won't work. Any thoughts? .after( $('img src=images/buttons/button_minus.gif alt=- class=decrement /') .bind('click', false, doPlusMinus) On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: hmm, seems like your original version should have that problem too. Maybe the increment and decrement operators take care of the conversion. At any rate, should be: $qty_field.val(parseInt($qty_field.val())-1); And: $qty_field.val(parseInt($qty_field.val())+1); --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Oh, one more thing, $qty_field.val($qty_field.val()-1); Is concatenating as a string, not adding! Just a small point, and nothing compared to the errors I'd make in coding without any testing!! Cheers, Dan. On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: No, not at all, many thanks to both - I still don't think it's beaten, but I'll have another look with what you and Jonathon's examples have given me (by example) in my understanding of chaining jquery. Jonathon's is very elegant, but needs some debugging to get it to work - I think I need to work through yours though, to cut the timing down, as it's still taking a while. If you have any further thoughts, though let me know... Thanks, Dan. On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: heh, I took so long writing my reply, a bunch of other people replied in the mean time. Anyways, I suggest you use firebug (console.time/console.timeEnd) to see how long each version takes. --Erik On 8/21/07, Erik Beeson [EMAIL PROTECTED] wrote: You do a lot of repetitive selecting. Something like this might help (untested): $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } }) .next().bind(click, function() { var $qty_field = $(this).siblings('[EMAIL PROTECTED]'); $qty_field.val($qty_field.val()+1); }); $(table.summarytable tr:even).addClass(odd); I removed the increment/decrement classes from the images to make the code more readable and because I'm not using them for selection anymore. If you need them there for styling or something, just add them back. Also, here's another version that may or may not be faster: $('td [EMAIL PROTECTED]').filter('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after('img src=images/buttons/button_minus.gif alt=- /img src=images/buttons/button_plus.gif alt=+ /') .each(function() { var $qty_field = $(this); $qty_field.siblings('img').bind('click', function() { if(this.alt == '+') { $qty_field.val($qty_field.val()+1); } else if(this.alt == '-') { if ($qty_field.val() 0 ) { $qty_field.val($qty_field.val()-1); } } }); }); $(table.summarytable tr:even).addClass(odd); Good luck with it. --Erik On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form
[jQuery] Re: Just my two cents Filter DIV by ID, NAME or other tags while typing
You have the response. If you read quietly the xhtml11-strict.dtd you will find that name attribute is not correct for a div, and only is for a input. You can use a class by example if your elements are repeated. So your example is not correct. Also, name in form elements is deprecated to using in JavaScript, is only for submit forms. In JavaScript you must use ID's. NccWarp9 escribió: Tried to find an example how to do this but found none. Search for DIV by NAME tag while typing Hide all divs but show only the ones that contain the search string. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http:// www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head script type=text/javascript src=jquery.js/script script type=text/javascript function search(val2){ $(div).hide(); $([EMAIL PROTECTED]+val2+]).show(); $(#lop).html(val2); } /script /head body form input onkeyup=search(this.value); /form div id=lop/divbr div name=abcABC/div div name=fdsFSD/div div name=rweREW/div div name=abaABA/div /body /html -- Best Regards, José Francisco Rives Lirola sevir1ATgmail.com SeViR CW · Computer Design http://www.sevir.org Murcia - Spain
[jQuery] Re: Just my two cents Filter DIV by ID, NAME or other tags while typing
Thanks for the comment, I wrote this in notepad and did not check for, or .. didn't care if it complied with standards, instead of name tag any tag can be used.like ID etc. The whole point was to provide an example on which someone could expand on. On Aug 21, 7:31 pm, SeViR [EMAIL PROTECTED] wrote: You have the response. If you read quietly the xhtml11-strict.dtd you will find that name attribute is not correct for a div, and only is for a input. You can use a class by example if your elements are repeated. So your example is not correct. Also, name in form elements is deprecated to using in JavaScript, is only for submit forms. In JavaScript you must use ID's. NccWarp9 escribió: Tried to find an example how to do this but found none. Search for DIV by NAME tag while typing Hide all divs but show only the ones that contain the search string. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http:// www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head script type=text/javascript src=jquery.js/script script type=text/javascript function search(val2){ $(div).hide(); $([EMAIL PROTECTED]+val2+]).show(); $(#lop).html(val2); } /script /head body form input onkeyup=search(this.value); /form div id=lop/divbr div name=abcABC/div div name=fdsFSD/div div name=rweREW/div div name=abaABA/div /body /html -- Best Regards, José Francisco Rives Lirola sevir1ATgmail.com SeViR CW Computer Design http://www.sevir.org Murcia - Spain
[jQuery] Re: Jquery toggle headache
Hi Pops, Thank you for your reply and quick scan. Yeah, I knew I had to explain what was actually happening that wasn't right, but I had a bit of trouble finding the right words ;-) What I was really saying with 'acting weird':. Let's say you have 3 list items and you click the first one, it opens the way it should (fade in). Clicking again closes the item as it should (fade out). You can repeat it over and over and it performs right. BUT, if you click for instance the second item (which also opens/closes as it should) and you click the first one again, instead of fading in it appears instantly, then flickers and does the fade in. Clicking doesn't fade it out, it does the same thing over and over. Basically you're ok clicking items you haven't opened yet, they all work properly, but click one you already have clicked, it does this. I've tested your code also, but it does the same this as described. Also, it looks as if your code doesn't like onclick AND onfocus. But this may be something I did wrong though ;-) Gonna try and tweak your code, see where it takes me. Thanks!! Gavin On Aug 21, 5:51 pm, Pops [EMAIL PROTECTED] wrote: Codex, I played with your code and this is what I found: Yes, It acted wierd! g First, I think that was because of the onFocus= on the a tag link which will fool with your mind depending on where is the current keyboard focus including switching browser pages. :-). Changing it to OnClick= begins to bring sanity to getting it worked out. Second, the toggle was being acted on the #mail_code id rather than the #prep-mail_code. If that is some cool trick you were thinking of, it certainly confused the hell out of mail Anyway, after that I changed you readmail() function to: function readmail (mail_code) { var $p = $('#prep-'+ mail_code); if ($p.is(:hidden)) { // Its hidden so toggled it on and do a AJAX call $p.toggle(); $.post(/jquery-fake-mail.wct, {}, function(response){ // Hide the spinner $(#spinner-+ mail_code).fadeOut(500); // Populate the prepared p-element with the response $(#prep-+ mail_code).html(response).fadeIn(500); } ); } else { // Its showing so slowly fade away and hide it $(#prep-+ mail_code).fadeOut(500); } return false; }; it was a thing of beauty! g Note, the .post() command. I have my fake url there so I can dump text for this testing . Put back your URL there and it should work. Finally, if you really wanted the onfocus, you can now better begin to explore that to auto-turn off stuff. But I would pay attention to window switching issues there. :-) -- HLS On Aug 21, 10:13 am, Pops [EMAIL PROTECTED] wrote: On Aug 20, 4:50 pm, Codex [EMAIL PROTECTED] wrote: It's sort of working, but the toggle seems to be acting weird. Can someone please go over the code and tell me what I might be doing wrong? A quick scan appears to be logical. What's wrong? Describe Acting Wierd. By not being specific, it forces people who may be interested in helping to actually spent more time to prepare a test bed to see what you see as wield. A good development tip as well as tip when seeking public help: Try to reduce your code to a plain vanilla example where there are no other dependencies, thus using divide and conquer techniques by separating the functional parts. You reduce the amount of people who can help when posting highly specific code. You never know. You might even find the problem by dividing and conquering each part. I know it does for me, atleast 99% of the time. :-) -- HLS
[jQuery] Re: Jquery toggle headache
What I was really saying with 'acting weird':. Let's say you have 3 list items and you click the first one, it opens the way it should (fade in). Clicking again closes the item as it should (fade out). You can repeat it over and over and it performs right. BUT, if you click for instance the second item (which also opens/closes as it should) and you click the first one again, instead of fading in it appears instantly, then flickers and does the fade in. Clicking doesn't fade it out, it does the same thing over and over. Basically you're ok clicking items you haven't opened yet, they all work properly, but click one you already have clicked, it does this. I've tested your code also, but it does the same this as described. Also, it looks as if your code doesn't like onclick AND onfocus. But this may be something I did wrong though ;-) Yes, this is behavior I saw too when you use onfocus in your A tag. Change that to Onclick and you will get what you want. -- HLS
[jQuery] Re: Incompatibility between jqem.js and jQuery 1.1.3
* RealET tapuscrivait, le 27/07/2007 18:05: * RealET tapotait, le 07/07/2007 17:01: On 4 juil, 21:02, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all, Since installing jQuery 1.1.3, a major memory problem has arisen in which 99% of the cpu is used. I did lots of tests and tracked it down tohttp://davecardwell.co.uk/javascript/jquery/plugins/jquery-em/0.2/ With FireBug, I tracked the problem further and it it the .width() that is performed every 100 millisecond that is responsible of the problem. You can see it on http://www.pyrat.net/ With FireBug, look at the body tag and you will notice that there is a style that is added to it : body style=position: static; then body style=position: relative; And so on. Anybody else have the bug ? and a solution ? For now, I've disabled the plugin on my sites, expecting resolution somedays... -- RealET
[jQuery] Re: Just my two cents Filter DIV by ID, NAME or other tags while typing
Selecting by ID's or ClassNames is simple with jQuery: $(#oneid, #anotherid).method(); $(.oneclass).method(...); but thinking in the hypothetical of you need to use non standard attributes, this example works for me: ?xml version=1.0 encoding=UTF-8? !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titlePageTitle/title script type=text/javascript src=http://jqueryjs.googlecode.com/files/jquery-1.1.3.1.pack.js;/script script type=text/javascript $(document).ready(function(){ $(#search_box).keyup(function(){ $(div).hide(); $([EMAIL PROTECTED]+this.value+]).show(); }); }); /script /head body form input id=search_box / /form div name=abcABC/div div name=fdsFSD/div div name=rweREW/div div name=abaABA/div /body /html NccWarp9 escribió: Thanks for the comment, I wrote this in notepad and did not check for, or .. didn't care if it complied with standards, instead of name tag any tag can be used.like ID etc. The whole point was to provide an example on which someone could expand on. On Aug 21, 7:31 pm, SeViR [EMAIL PROTECTED] wrote: -- Best Regards, José Francisco Rives Lirola sevir1ATgmail.com SeViR CW · Computer Design http://www.sevir.org Murcia - Spain
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Sending code via e-mail stinks! The basic logic for the after is: // Append our images $(...).after( // Create a new image element $('img src=images/buttons/button_minus.gif alt=- class=decrement /') // Bind your click event to it .bind('click', false, doPlusMinus) // Add the sceond image element after it .after( // You may be able to substitue add (to select this element for this object) for this after call // Create your element and bind the event to it $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ) Cheers, -js On 8/21/07, Jonathan Sharp [EMAIL PROTECTED] wrote: This can be reduced to this: $(document).ready(function() { function doPlusMinus(event) { qty_field = $(this).parent('td').find('[EMAIL PROTECTED]'); var num = $(qty_field).val(); $(qty_field).val( num + ( event.data === true ? 1 : (num 0 ? -1 : 0)) ); } // Find our input fields, append a minus plus image (create minus image, add plus image after minus image) $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after( $('img src=images/buttons/button_minus.gif alt=- class=decrement /') .bind('click', false, doPlusMinus) .after( $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ); $(table.summarytable tr:even).addClass(odd); }); Cheers, -js On 8/21/07, seedy [EMAIL PROTECTED] wrote: You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); if (numValue 0 ) { numValue--; } $(qty_field).val(numValue); }); } -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- View this message in context: http://www.nabble.com/Iterating-over-1000-items---optimizing-jquery-tf4306183s15494.html#a12258350 Sent from the JQuery mailing list archive at Nabble.comhttp://nabble.com/ .
[jQuery] Problem with easing function was: accordion adventures
I'm writing inverted hover accordion plug in. In order to fully reproduce Apple.com menu, easing function is essential. I'm using easing function copied from Interface. That easing function causes menu to jumps. In plain version (non-plugin) this function behaves nicely. Any clues, please? plugin: http://www.bydot.net/iccordion/ original: http://www.bydot.net/hoveracc/ -- Dragan Krstić krdr http://krdr.ebloggy.com/
[jQuery] Re: Iterating over 1000 items - optimizing jquery
I've got this: $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /) .next([EMAIL PROTECTED]'-']).bind('click', false, doPlusMinus) .next([EMAIL PROTECTED]'+']).bind('click', true, doPlusMinus); Which works, but the two 'nexts' are adding maybe a second each, if I can get rid of them and get to your code, it'd be fine, but I don't think that you can bind an event to the html added by after: $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after( $(img src='images/buttons/button_minus.gif' alt='-' class=\decrement\ /).bind('click', false, doPlusMinus) ).after( $(img src='images/buttons/button_plus.gif' alt='+' class=\increment\ /).bind('click', true, doPlusMinus) ); That doesn't work... although it clocks in at just over a second for 1000 inputs. I think the added code needs to be a jquery object /node collection, for the bind to 'bind' to. On 8/21/07, Jonathan Sharp [EMAIL PROTECTED] wrote: Sending code via e-mail stinks! The basic logic for the after is: // Append our images $(...).after( // Create a new image element $('img src=images/buttons/button_minus.gif alt=- class=decrement /') // Bind your click event to it .bind('click', false, doPlusMinus) // Add the sceond image element after it .after( // You may be able to substitue add (to select this element for this object) for this after call // Create your element and bind the event to it $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ) Cheers, -js On 8/21/07, Jonathan Sharp [EMAIL PROTECTED] wrote: This can be reduced to this: $(document).ready(function() { function doPlusMinus(event) { qty_field = $(this).parent('td').find('[EMAIL PROTECTED]'); var num = $(qty_field).val(); $(qty_field).val( num + ( event.data === true ? 1 : (num 0 ? -1 : 0)) ); } // Find our input fields, append a minus plus image (create minus image, add plus image after minus image) $('[EMAIL PROTECTED],[EMAIL PROTECTED]') .after( $('img src=images/buttons/button_minus.gif alt=- class=decrement /') .bind('click', false, doPlusMinus) .after( $('img src=images/buttons/button_plus.gif alt=+ class=increment /').bind('click', true, doPlusMinus) ) ); $(table.summarytable tr:even).addClass(odd); }); Cheers, -js On 8/21/07, seedy [EMAIL PROTECTED] wrote: You shouldn't need to use the .each $('td [EMAIL PROTECTED]@type=text]').after('stuff') will append to all elements that match the selector, no need to go into a loop with each. Dan Eastwell wrote: Hi, I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly. There is no way I can change the number of items, it's a given and a piece of business 'logic'. The jquery I have comprises four simple functions to add increment/decrement buttons to the order form to increase quantities, and a jquery addClass call to add pajama/zebra stripes to the table. There are two quantity fields (again for business reasons), so that's over a 1000 items. http://test2.danieleastwell.co.uk/test2/master_order_test.html The problem is it causes a 'script hanging' error IE7 on, I'm guessing, slower machines (not mine), and takes ~10secs in Firefox2 (with firebug/validation tools) to load. Is there any way I can optimize this to load any more quickly, or do I need to give up on scripting to add the items and their functionality? Many thanks, Dan. $(document).ready(function() { addPlusMinus(td [EMAIL PROTECTED]@type=text]); addPlusMinus(td [EMAIL PROTECTED]@type=text]); increment(#order_form img.increment); decrement(#order_form img.decrement); $(table.summarytable tr:even).addClass(odd); }); function addPlusMinus(input_text){ $(input_text).each( function(){ $(this).after( images/buttons/button_minus.gif images/buttons/button_plus.gif ); }); } function increment(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue = $(qty_field).val(); numValue++; $(qty_field).val(numValue); }); } function decrement(image_button) { $(image_button).bind(click, function() { qty_field = $(this).parent(td).find([EMAIL PROTECTED]); var numValue
[jQuery] Re: Problems with VALIDATE PLUGIN
Jean schrieb: I´m so sorry!!! At least you got me thinking about that method name. If it says jQuery(element).metadata() is not a function the solution would be much more obvious. -- Jörn
[jQuery] Re: Hiding and Showing behavior, where to mouseout?
Take a look at the .hover() method
[jQuery] Re: Tablesorter 2.0
I have what I guess would be a feature request for the tablesorter. Some of our larger tables take a few seconds to sort and I would like to be able to display a message for our users to indicate that a sort is in progress. So basically, user clicks on th, message overlays table saying sort in progress, then when sort finishes, message is removed. I explored the options available via widgets, but it appears that the widgets are only called when the tablesorter is initially attached to the table, and then again when the sort is complete. Would it be possible to have a 'callforward' (don't know what to call the opposite of a callback) that would allow for writing a widget to display this user notification message? Or can anyone suggest another method for doing this type of notification? On Aug 21, 4:09 am, lukek [EMAIL PROTECTED] wrote: This is interesting. I was thinking along these lines but was interested to know how you - being the designer - would implement it. Thanks for you help. I'll tell you what I am working on at the moment. I'd be interested to know what you thoughts are, if you have any pointers or have thought about this kind of thing yourself. I have a sortable Document History table for a collaborative document-writing app (eg the table has columns such as Doc name, last mod timestamp, last user, link to D/L the doc). There will eventually be history tables for multiple documents on one page. I am mashing up your Tablesorter with Remy Sharp's Spy. What has been interesting so far is: * reloading all the widgets after an ajax prependage to the table. I am having trouble deciding the best way to update the widgets this when the 'update' event is triggered. * These other widgets bind clicks events to elements in the new table rows as well as doing things like zebra striping the rows. This makes the browser go crazy as its trying to handle events and adding rows all at once. * The point of mashing other plugins with the tablesorter using the widget system:- Currently the mashed widget has to be added before the settings for for said plugin are added to tablesorter. ie $(table).tablesorter({ widgets: [mashWidget], widgetMashSettings : { url : 'somejson.php', callback : insertJsonIntoTable, timeout : 3000 } }); I haven't even started on resorting the table after rows are added yet... This widget thing is so exciting to me. Hopefully it will encourage a whole load of activity form the community - a widget repository might be nice! cheers Luke Oh yeah - and I have a plan dynamically loading date parsers based on locale settings. On 20 Aug, 23:17, Christian Bach [EMAIL PROTECTED] wrote: Hi Lukek, I took an other approach to this. Check out:http://tablesorter.com/docs/example-extending-defaults.html Regards Christian 2007/8/20, lukek [EMAIL PROTECTED]: Been having a further poke around. I have done what Christian suggested and merged the widgets and parser arrays of this.config with those in settings. However now I have realised the constructor is being called twice - or the number of levels of inheritance. So many options not sure what to do... On Aug 20, 9:33 am, lukek [EMAIL PROTECTED] wrote: Thanks for getting back Christian - only just seen you post. I look forward to the fix. I will tinker with it and see what I come up with until then. By the way I had another question. -- In the unpacked version of the latest script your comment on line 555 says apply easy methods that trigger binded events. Does this mean I can insert function calls in here - ie around line 560? I say this because I have added a call to applyWidget() as I reckon all the widgets should be reloaded when the update event is triggered - eg after I insert rows I want to reapply the zebra widget. Unless I missed something or your plan was to control this action in some other way. Thanks Luke On Aug 17, 10:36 pm, Christian Bach [EMAIL PROTECTED] wrote: Lukek, I will supply a fix for this after the weekend. If you cant wait that long a tip is that if this.config exists that should be extended instead of the defaults. /christian 2007/8/17, lukek [EMAIL PROTECTED]: Hi, I have just been playing with the newTablesorter2.0. Thanks Mr Bach! Great piece of work. I am having problems getting tables to inherit widgets. I am not sure if its the way $.extend() merges arrays when passing the settings object to thetablesorter.construct() function or what but when I add more widgets it seems to overwrite the ones I added previously. EXAMPLE: table class=data id=myTable1 .../table table class=data id=myTable2 .../table script $(table.data).tablesorter( {
[jQuery] Re: Iterating over 1000 items - optimizing jquery
From: Dan Eastwell I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly... Can't you do any of this on the server? All of the code generation - the IMG tags and the zebra striping - would cost next to nothing while the page is being generated on the server. And if the page is gzipped it wouldn't even take much extra download time. Then, instead of binding event handlers to all of the individual buttons, just bind a single event handler to the parent form: $('#order_form').click( function( event ) { var $target = $(event.target); if( $target.is('img.increment') ) return change( 1 ); if( $target.is('img.decrement') ) return change( -1 ); function change( by ) { var $qty = $target.parent('td').find('[EMAIL PROTECTED]'); var n = +$qty.val() + by; if( n = 0 ) $qty.val( n ); return false; } }); Even if you have to do the code generation in JavaScript, you can use this technique to eliminate all the individual event binding and cut the JavaScript load time overhead to virtually nothing. Let us know if the JavaScript code generation is really mandatory - I saw the other replies but there are still a few remaining tricks to speed it up. -Mike
[jQuery] Re: Iterating over 1000 items - optimizing jquery
Thanks for the reply, Mike, The thinking behind it is not to add the button images using javascript, so that if you don't have javascript, you don't have useless and confusing buttons. I'll try your form event handle, so thanks for that, Dan. On 8/21/07, Michael Geary [EMAIL PROTECTED] wrote: From: Dan Eastwell I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly... Can't you do any of this on the server? All of the code generation - the IMG tags and the zebra striping - would cost next to nothing while the page is being generated on the server. And if the page is gzipped it wouldn't even take much extra download time. Then, instead of binding event handlers to all of the individual buttons, just bind a single event handler to the parent form: $('#order_form').click( function( event ) { var $target = $(event.target); if( $target.is('img.increment') ) return change( 1 ); if( $target.is('img.decrement') ) return change( -1 ); function change( by ) { var $qty = $target.parent('td').find('[EMAIL PROTECTED]'); var n = +$qty.val() + by; if( n = 0 ) $qty.val( n ); return false; } }); Even if you have to do the code generation in JavaScript, you can use this technique to eliminate all the individual event binding and cut the JavaScript load time overhead to virtually nothing. Let us know if the JavaScript code generation is really mandatory - I saw the other replies but there are still a few remaining tricks to speed it up. -Mike -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Iterating over 1000 items - optimizing jquery
That is genius Mike, I'm extremely grateful. It worked perfectly - even with adding my images using jquery, the total time was ~1.2 secs, which I see as acceptable for 1000 inputs. Many thanks once more, Dan. PS - if it's not too much trouble, could you explain /why/ it works? Especially the event.target selector, what's that? I didn't really get target from the documentation, and what's the 'event' parameter? thanks. On 8/21/07, Dan Eastwell [EMAIL PROTECTED] wrote: Thanks for the reply, Mike, The thinking behind it is not to add the button images using javascript, so that if you don't have javascript, you don't have useless and confusing buttons. I'll try your form event handle, so thanks for that, Dan. On 8/21/07, Michael Geary [EMAIL PROTECTED] wrote: From: Dan Eastwell I'm doing an order form for a bookstore. The order form has over 500 items in it, so jquery runs slowly... Can't you do any of this on the server? All of the code generation - the IMG tags and the zebra striping - would cost next to nothing while the page is being generated on the server. And if the page is gzipped it wouldn't even take much extra download time. Then, instead of binding event handlers to all of the individual buttons, just bind a single event handler to the parent form: $('#order_form').click( function( event ) { var $target = $(event.target); if( $target.is('img.increment') ) return change( 1 ); if( $target.is('img.decrement') ) return change( -1 ); function change( by ) { var $qty = $target.parent('td').find('[EMAIL PROTECTED]'); var n = +$qty.val() + by; if( n = 0 ) $qty.val( n ); return false; } }); Even if you have to do the code generation in JavaScript, you can use this technique to eliminate all the individual event binding and cut the JavaScript load time overhead to virtually nothing. Let us know if the JavaScript code generation is really mandatory - I saw the other replies but there are still a few remaining tricks to speed it up. -Mike -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog -- Daniel Eastwell Portfolio and articles: http://www.thoughtballoon.co.uk Blog: http://www.thoughtballoon.co.uk/blog
[jQuery] Re: Cycle Plugin Killing me
Mike is it possible that there is still a bug or am I just doing something really dumb here: http://www.whatbird.com/wwwroot/Components/cycle%20demo2.html I see the first image but no cycling. Firebug I would like to point out something that I think would make your cycle plugin much easier to use which is this. This page starts out great by showing you the exact code you need to enter. But its not complete. You dont show everything that you need. The container in your excellent examples is #S1. That really confused me. In other words assuming this is correct code I believe your plugin and every other one would be so more accessible if you just added this to the example page link href=../css/cycle.css rel=stylesheet type=text/css / script src=../js/jquery.js type=text/javascript/script script src=../js/jquery.cycle.all.js type=text/javascript/ script script type=text/javascript $(document).ready(function(){ /* $('#birds').cycle('fade'); */ $('#birds').cycle( { fx: 'scrolldown', speed: 300, timeout: 2000 } ); }); /script /head body div id=birds class=pics img src=../images/Acadian Flycatcher_X2.jpg / img src=../images/Acorn Woodpecker_X2.jpg / img src=../images/Alder Flycatcher_X2.jpg //div /body /html Anway thats my nickle. Mitch On Aug 21, 7:42 am, Mike Alsup [EMAIL PROTECTED] wrote: Mitch, I've just fixed a bug in the scroll transitions. v1.8 is available now and should fix the problem. Give me a shout if you're still having troubles. http://www.malsup.com/jquery/cycle/download.html Mike I got it to work, thank you guys, as you can see here (wait a few seconds for the fade to occur). http://www.whatbird.com/wwwroot/Components/cycle%20demo.html However I cant get the special effects to work. For example this link, which uses $('#birds').cycle( {fx: 'scrollDown'} ); should do a scroll down: http://www.whatbird.com/wwwroot/Components/cycle%20demo2.html Instead nothing happens.- Hide quoted text - - Show quoted text -
[jQuery] Re: Iterating over 1000 items - optimizing jquery
From: Dan Eastwell The thinking behind it is not to add the button images using javascript, so that if you don't have javascript, you don't have useless and confusing buttons. You can still generate the code on the server. Just use this code in head: style type=text/css img.increment, img.decrement { display: none; } /style script type=text/javascript document.write( 'style type=text/css img.increment, img.decrement { display: inline; } \/style' ); /script My gut sense is that you'll get a more responsive page this way instead of trying to optimize the JavaScript code. -Mike
[jQuery] Re: Cycle Plugin Killing me
On Aug 21, 9:32 pm, Mitch [EMAIL PROTECTED] wrote: ... I would like to point out something that I think would make your cycle plugin much easier to use which is this. ... div id=birds class=pics img src=../images/Acadian Flycatcher_X2.jpg / img src=../images/Acorn Woodpecker_X2.jpg / img src=../images/Alder Flycatcher_X2.jpg //div Speaking of improvement, here's my idea: It would be nice to be able to pass additional images to the plugin function call. The reason for this is to support Unobtrusive JS: in the DIV you have a single IMG file which will show up whether or not JS is available. When the plugin is called, if it is passed an array of image names, those images are added before the plugin does the rest of its processing. This allows the JS users to have a cycling show and the non-JS users to see the first image without any effects. As proof of concept, here's some code for a trivial image cycler which demonstrates this feature... the part to look at is the addImages stuff: /// // Miniature jQuery plugin for rotating through a set of images. jQuery.fn.goshenImageFader = function( options ) { options = jQuery.extend({ fadeOutSpeed:750, fadeInSpeed:500, delay:4500, addImages:[], forceImgAttr:null },options); if( options.addImages.length ) { for( var i = 0; i options.addImages.length ; ++i ) { var img = jQuery(img/); img.hide() .attr('src',options.addImages[i]) .appendTo(this); } } var imgs = jQuery('img',this); imgs.gt(0).hide(); if( options.forceImgAttr ) { for( var k in options.forceImgAttr ) { imgs.attr(k,options.forceImgAttr[k]); } } var pos = 0; var current = 0; function cycle() { function doIn(to) { imgs.eq(to).fadeIn( options.fadeInSpeed ); } function doOut(from,to) { imgs.eq(from).fadeOut( options.fadeOutSpeed, function(){doIn(to)} ); } pos = (pos = (imgs.length-1)) ? 0 : ++pos; doOut( current, pos ); current = pos; }; setInterval( cycle, options.delay ); return this; }; It's then called like so: $('#FrontPageImageFader').goshenImageFader({ addImages:[ '/pics/homes/timberframe/thumb-50/ Kitchen_view_frontpage_byGoshens.jpg', '/pics/homes/timberframe/WalnutCreek_Porch- front.jpg', '/pics/homes/timberframe/LaurelGap-Loft2.jpg' ] }); i think a similar feature would be trivial to add to Cycle and would help Cycle gracefully degrade in browsers w/o JS.
[jQuery] Re: Iterating over 1000 items - optimizing jquery
From: Michael Geary Then, instead of binding event handlers to all of the individual buttons, just bind a single event handler to the parent form: $('#order_form').click( function( event ) { var $target = $(event.target); if( $target.is('img.increment') ) return change( 1 ); if( $target.is('img.decrement') ) return change( -1 ); function change( by ) { var $qty = $target.parent('td').find('[EMAIL PROTECTED]'); var n = +$qty.val() + by; if( n = 0 ) $qty.val( n ); return false; } }); From: Dan Eastwell That is genius Mike, I'm extremely grateful. It worked perfectly - even with adding my images using jquery, the total time was ~1.2 secs, which I see as acceptable for 1000 inputs. That's great, Dan. I was going to give you the usual this is untested code warning, so I'm surprised and pleased that it worked out of the box. :-) Handling events on a parent element works so well that it's one of the first things I think of for cases like this. No reason to do something 1000 times when 1 will do. :-) PS - if it's not too much trouble, could you explain /why/ it works? Especially the event.target selector, what's that? I didn't really get target from the documentation, and what's the 'event' parameter? Sure. These two doc pages should explain it - give a shout back if you have questions about them: http://docs.jquery.com/Events http://docs.jquery.com/Events_%28Guide%29 The one thing those pages don't explain is the whole concept of event bubbling, but there are plenty of resources on that: http://www.google.com/search?q=javascript+event+bubbling For the purposes of this particular technique, though, you don't really need to get into all the details of event bubbling - just note that you can listen for an event either on the target element itself or on any parent of that element. -Mike
[jQuery] Re: Problems with VALIDATE PLUGIN
Jean schrieb: Really lol Dude i´m with a little problem to append the error msg in the right place look my structure ul label for='perg9'strongPergunta 9/strong: Qual o faturamento anual da empresa?/labelbr / input type='hidden' id='p9' name='p9' value='110' li//Here is the supost place/li liinput type='radio' name='perg9' id='perg9' class='{required:true}' value = '105' / Até R$ 240.000/li liinput type='radio' name='perg9' id='perg9' class='{required:true}' value = '83' /De R$ 240.001 a R$ 2.400.000/li liinput type='radio' name='perg9' id='perg9' class='{required:true}' value = '84' /De R$ 2.400.001 a R$ 60.000.000/li liinput type='radio' name='perg9' id='perg9' class='{required:true}' value = '106' /Acima de R$ 60.000.001/li/ul Isnt errorElement : li, ?? if a i can append between /label li is better. i´m trying a lot diferent elements but it returns in the same position always =/ errorElement alone won't help. Check the example for errorPlacement: $(#myform).validate({ errorPlacement: function(error, element) { error.appendTo( element.parent(td).next(td) ); } }); -- Jörn
[jQuery] Re: Paul Bakaus on Ajaxian
Hi again, very insightful to read all these great comments. short circuit just didn't came to my mind at the time of writing (d'oh). The example above with the 's' variable is very interesting. I'll have to investigate this one a bit further. Indeed, I should probably read a bit about bitwise operators again and there real usage, maybe it's worth using them in more cases (than my dirty hack for doing multiple statements). And yes, condition == true ? is absolutely stupid. It destroys boolean thinking, I actually should have written condition ?. Paul On Aug 21, 3:09 am, Pops [EMAIL PROTECTED] wrote: I have to check that out. I guess it depends on the compiler or intepreter. It's pretty rare for anything like this to depend on the compiler or interpeter. We are still talking about short circuits? For bitwise conditions. It can be larged based on only compiler/ interpreter but machine word size. This is in fact, a could be a common bug in code: if (a b) versusif ((a b) == b) depending on the language compiler/interpreter, the machine word size and the language word size. The latter is 100% guarantee to be correct, the former, you typically is ok, but you can not be confident that it will be. Operator semantics are a pretty basic part of the core JavaScript language, and you should be able to count on that expression working the same in any JavaScript implementation. Is that basically because there is only one JavaScript source everyone is using? :-) -- HLS
[jQuery] Re: Paul Bakaus on Ajaxian
From: Michael Geary It's pretty rare for anything like this to depend on the compiler or interpeter. From: Pops We are still talking about short circuits? I think so. :-) For bitwise conditions. It can be larged based on only compiler/ interpreter but machine word size. This is in fact, a could be a common bug in code: if (a b) versusif ((a b) == b) depending on the language compiler/interpreter, the machine word size and the language word size. The latter is 100% guarantee to be correct, the former, you typically is ok, but you can not be confident that it will be. What language are you talking about? if( a b ) is perfectly good, portable code in either C (assuming reasonable types for a and b) or JavaScript. Operator semantics are a pretty basic part of the core JavaScript language, and you should be able to count on that expression working the same in any JavaScript implementation. Is that basically because there is only one JavaScript source everyone is using? :-) No, but there is one standard they are all using: http://www.ecma-international.org/publications/standards/Ecma-262.htm -Mike
[jQuery] jCorner problem?
This is the result I am expecting -- http://www.augustine.com/images/test/expected.jpg . This is what I get -- http://www.augustine.com/images/test/actual.jpg . I am using standard corner syntax, $(this).corner(); .. this 'actual' result only occurs in Internet Explorer when the page is refreshed with the cursor ON the window, if you move it away from the window you get the 'expected.jpg' result, thoughts? workarounds? Thanks ahead of time.
[jQuery] Re: Cycle Plugin Killing me
@mitch: What exactly is missing from the examples? Is it just the container ID that confused you? On the beginner demo I tried to clearly show how the markup and CSS should look but I didn't want to show that over and over for each and every demo. @Stephan: Interesting idea. For now I'm going to try to keep the Cycle Plugin as lean as possible. It's already grown much larger than I had intended. As an FYI, Cycle is for more than just images. Thanks for the feedback! Mike But its not complete. You dont show everything that you need. The container in your excellent examples is #S1. That really confused me.
[jQuery] Testing IE6 and IE7 with Virtual PC
Hi, two new VPC images for IE6 and IE7 on Win XP SP2 are now available: http://www.microsoft.com/downloads/details.aspx?FamilyID=21eabb90-958f-4b64-b5f1-73d0a413c8efDisplayLang=en With these images you can test web applications in each browser on a pre-activated XP SP2 virtual machine in your own Windows environment, especially if you're running Vista. You need Virtual PC 2007 to run it, which is available for free here: http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx The latter is also nice for creating a Linux test environment you can run from within Windows. Happy testing, Bernd
[jQuery] Re: Prechecking the browser before loading jQuery
jQuery has some built-in browser agent tools: From http://jquery.com/api $.browser returns Boolean Contains flags for the useragent, read from navigator. Contains flags for the useragent, read from navigator.userAgent. Available flags are: safari, opera, msie, mozilla This property is available before the DOM is ready, therefore you can use it to add ready events only for certain browsers. There are situations where object detections is not reliable enough, in that cases it makes sense to use browser detection. Simply try to avoid both! A combination of browser and object detection yields quite reliable results. Example: Returns true if the current useragent is some version of microsoft's internet explorer $.browser.msie Example: Alerts this is safari! only for safari browsers if($.browser.safari) { $( function() { alert(this is safari!); } ); } Does this help? Glen On 8/21/07, Dekortage [EMAIL PROTECTED] wrote: Hey all... I've been experimenting with jQuery a lot, and really like the functionality it provides. However, there are times when I'd like to use jQuery, but need to provide an alternative site for people with older browsers (particularly visitors from rural locations in developing countries, who often have much older and slower technology). So, I need to detect the browser and make sure it can support jQuery. Here is the basic code I've developed, which I've tested in a handful of browsers. // object detection for jQuery-supported browsers var isIE = (document.compatMode document.all); // IE 6+ var isFF = (Array.every || window.Iterator); // FF 1.5+ var isOther = (typeof document.documentElement.style.maxHeight != undefined) (!document.all); // Safari, Opera... var jQ = false; // act on browser type if (!isIE !isFF !isOther) { window.location.replace(index2.html); } else { jQ = true; document.write('script language=javascript src=jquery.js\/ script'); document.write('script language=javascript src=extras.js\/ script'); } You can test this at http://www.tordevries.com/browser-check/. The code uses object detection to identify browsers, though I'm not sure this is the most optimal way of doing it. If none of the detection booleans is true, the user is booted to a backup page (index2.html); otherwise, the script dynamically loads jQuery and an external JavaScript file. (I use a meta-refresh tag in the noscript tag to forward people who have disabled JavaScript.) Oddly, if you use $(document).ready in the dynamically-loaded extras.js file, Safari won't load it. I can't figure out why. Other browsers are fine. So I fall back to an onLoad trigger in the body tag, referencing a function in the extras.js file. Unfortunately, older browsers (like IE 5 on the Mac) may trigger onLoad before they get forwarded to the secondary page, thus generating an error because the function hasn't been loaded. Thus, the body tag actually looks like this: body onLoad=if (jQ) init(); If jQ is true, then onLoad can safely fire the init() function. Otherwise it's ignored. So... thoughts? comments? Does the test page work for you? Is there a better way to do this? Thanks in advance. -tdv
[jQuery] Re: Cycle Plugin Killing me
Specifically I was confused that the ID was missing from the pics container. Besides adding an ID to the container code I suggest that your js download contain a sample of ONE effect, the images and css. Lots of people do that and what is so nice is you can open there index.htm and immediately have it working, then start modifying or insidertinto your own code. Mitch On Aug 21, 2:16 pm, Mike Alsup [EMAIL PROTECTED] wrote: @mitch: What exactly is missing from the examples? Is it just the container ID that confused you? On the beginner demo I tried to clearly show how the markup and CSS should look but I didn't want to show that over and over for each and every demo. @Stephan: Interesting idea. For now I'm going to try to keep the Cycle Plugin as lean as possible. It's already grown much larger than I had intended. As an FYI, Cycle is for more than just images. Thanks for the feedback! Mike But its not complete. You dont show everything that you need. The container in your excellent examples is #S1. That really confused me.- Hide quoted text - - Show quoted text -
[jQuery] Re: Cycle Plugin Killing me
JS: in the DIV you have a single IMG file which will show up whether or not JS is available I would like it so only ONE image showed when you were viewing in your editor instead of all images being stacked on top of each other. On Aug 21, 12:51 pm, Stephan Beal [EMAIL PROTECTED] wrote: On Aug 21, 9:32 pm, Mitch [EMAIL PROTECTED] wrote: ... I would like to point out something that I think would make your cycle plugin much easier to use which is this. ... div id=birds class=pics img src=../images/Acadian Flycatcher_X2.jpg / img src=../images/Acorn Woodpecker_X2.jpg / img src=../images/Alder Flycatcher_X2.jpg //div Speaking of improvement, here's my idea: It would be nice to be able to pass additional images to the plugin function call. The reason for this is to support Unobtrusive JS: in the DIV you have a single IMG file which will show up whether or not JS is available. When the plugin is called, if it is passed an array of image names, those images are added before the plugin does the rest of its processing. This allows the JS users to have a cycling show and the non-JS users to see the first image without any effects. As proof of concept, here's some code for a trivial image cycler which demonstrates this feature... the part to look at is the addImages stuff: /// // Miniature jQuery plugin for rotating through a set of images. jQuery.fn.goshenImageFader = function( options ) { options = jQuery.extend({ fadeOutSpeed:750, fadeInSpeed:500, delay:4500, addImages:[], forceImgAttr:null },options); if( options.addImages.length ) { for( var i = 0; i options.addImages.length ; ++i ) { var img = jQuery(img/); img.hide() .attr('src',options.addImages[i]) .appendTo(this); } } var imgs = jQuery('img',this); imgs.gt(0).hide(); if( options.forceImgAttr ) { for( var k in options.forceImgAttr ) { imgs.attr(k,options.forceImgAttr[k]); } } var pos = 0; var current = 0; function cycle() { function doIn(to) { imgs.eq(to).fadeIn( options.fadeInSpeed ); } function doOut(from,to) { imgs.eq(from).fadeOut( options.fadeOutSpeed, function(){doIn(to)} ); } pos = (pos = (imgs.length-1)) ? 0 : ++pos; doOut( current, pos ); current = pos; }; setInterval( cycle, options.delay ); return this; }; It's then called like so: $('#FrontPageImageFader').goshenImageFader({ addImages:[ '/pics/homes/timberframe/thumb-50/ Kitchen_view_frontpage_byGoshens.jpg', '/pics/homes/timberframe/WalnutCreek_Porch- front.jpg', '/pics/homes/timberframe/LaurelGap-Loft2.jpg' ] }); i think a similar feature would be trivial to add to Cycle and would help Cycle gracefully degrade in browsers w/o JS.
[jQuery] Re: Cycle Plugin Killing me
Besides adding an ID to the container code I suggest that your js download contain a sample of ONE effect, the images and css. Lots of people do that and what is so nice is you can open there index.htm and immediately have it working, then start modifying or insidertinto your own code. That's a good idea. Mike
[jQuery] Re: Testing IE6 and IE7 with Virtual PC
Thanks for the info Bernd. On 8/21/07, Bernd Matzner [EMAIL PROTECTED] wrote: Hi, two new VPC images for IE6 and IE7 on Win XP SP2 are now available: http://www.microsoft.com/downloads/details.aspx?FamilyID=21eabb90-958f-4b64-b5f1-73d0a413c8efDisplayLang=en With these images you can test web applications in each browser on a pre-activated XP SP2 virtual machine in your own Windows environment, especially if you're running Vista. You need Virtual PC 2007 to run it, which is available for free here: http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx The latter is also nice for creating a Linux test environment you can run from within Windows. Happy testing, Bernd -- Benjamin Sterling http://www.KenzoMedia.com http://www.KenzoHosting.com
[jQuery] Re: jCorner problem?
On Aug 21, 9:58 pm, Mark [EMAIL PROTECTED] wrote: This is the result I am expecting --http://www.augustine.com/images/test/expected.jpg . This is what I get --http://www.augustine.com/images/test/actual.jpg . I am using standard corner syntax, $(this).corner(); .. this 'actual' result only occurs in Internet Explorer when the page is refreshed with the cursor ON the window, if you move it away from the window you get the 'expected.jpg' result, thoughts? workarounds? Can you tell us what browser/version you're using, and what jQuery and jCorner versions? Also, if you can provide a link to a page demonstrating the problem, that would be really helpful. :)
[jQuery] Testing and Validating extension tips
... and while we're at it: Paul Annesley, another avid jQuery user, left an interesting Firefox extension link in an Ajaxian comment: http://www.sitepoint.com/dustmeselectors/ Nice one to find unused css selectors. And being a validation fetishist, I would like to recommend this http://www.totalvalidator.com/ to anyone in search of a one-stop validation solution for both (X)HTML and WCAG. If you buy the full version, you'll also get screenshot service for those browsers you don't have available. I'm currently building a RIA using Zend Framework and jQuery, and it's a pain to make this work in IE6 and Opera, so these tools are helping me big time... Bernd
[jQuery] Re: Dinamically add elements to a existing jCarouselLite
hi thorfinn, Using the present featureset of jCarouselLite, you will not be able to add content at run-time once the carousel is initialized. You have 2 options 1. To add the li elements before u even initialize the carousel 2. look into jCarousel. Although a bit heavy, it has a host of features that jCarouselLite does not support. Lemme know if you have further questions. -GTG On 8/21/07, thorfinn [EMAIL PROTECTED] wrote: Hi jQuery folks, i'm trying to create a page where a new li element is to be added to an existing carousel. The new element's content is coming from some ajax call and it should fit dinamically into the existing carousel forcing it to reinitialize (i suppose). Ex. THIS IS THE HTML MARKUP OF THE ORIGINAL CAROUSEL div id=carousel ul id=carouselList lihtml markup content/li /ul /div --JCAROUSELLITE JAVASCRIPT INIT CODE $(#carousel).jCarouselLite({ btnGo: new Array(#historyGo1), visible:1, circular:false }); --- suppose that on completion of aN ajax request we get some other html code, then we should be supposed to add it to a new li element appended to the ul this way: $(ul#carouselList).append(li+new html code from ajax+/li); - Now i suppose that i should reinitialize the carousel but it doesent seem to work that way! Since i'm getting lots of troubles doing that, i would greatly appreciate if anyone can point me to some hints or existing documentation... Thanks in advance! thorfinn
[jQuery] Re: Testing IE6 and IE7 with Virtual PC
On Aug 21, 11:26 pm, Bernd Matzner [EMAIL PROTECTED] wrote: You need Virtual PC 2007 to run it, which is available for free here:http://www.microsoft.com/windows/products/winfamily/virtualpc/default... The latter is also nice for creating a Linux test environment you can run from within Windows. Another alternative for running a Linux environment from Windows is the Free (GPL'd) qemu tool (http://fabrice.bellard.free.fr/qemu/), which runs under Linux, Mac OS/X, Windows, and OpenSolaris (and probably others). You can find several pre-configured Linux images for qemu on my web site: http://wanderinghorse.net/computing/qemu/ Simply download an image and open it with qemu and you're all set. You may need to install Apache and whatnot, but for some images (e.g. Debian) that is trivial as long as the qemu network emulation is working (it normally does). :D
[jQuery] Killing ajax calls
I'm working on a function that sends far too many ajax calls, an easy way to take care of the problem would be to kill all ajax calls before sending a new one (i.e. if it isn't done yet, nvm the result) the xhr object idea works for one call or if you know all the previous calls but I simply want to kill ANY ajax calls currently not completed...
[jQuery] Re: Killing ajax calls
Can we get a description of what you are doing? There shouldnt be a reason for a function to send tons of ajax calls. Either condense them to 1, or use a different method. On 8/21/07, Tamm [EMAIL PROTECTED] wrote: I'm working on a function that sends far too many ajax calls, an easy way to take care of the problem would be to kill all ajax calls before sending a new one (i.e. if it isn't done yet, nvm the result) the xhr object idea works for one call or if you know all the previous calls but I simply want to kill ANY ajax calls currently not completed...