[jQuery] Re: $.( 'a:link' )
On Feb 23, 1:55 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: That was a good idea, Klaus - but it's having the same effect as plain a. As the script's written it inline, it overrides the visited, hover active styles. Surely there must be a way round this, without adding yet another stylesheet ... Even if jQuery hasn't got it covered, would it be possible to add another filter, like :first, only :link? I'll have a go if someone can point me to the instructions ;) I'm all ears (or eyes)! As far as I know there's now way to reimplement the link pseudo classes in JavaScript. I read somewhere that you could check for the color of a link to determine its visited state, but that would require having a different color declared for these links... --Klaus
[jQuery] Re: div select and change it's css
Very kewl, but any tips on getting the key up / key down navigation hooked up as well? On Feb 16, 10:02 am, George [EMAIL PROTECTED] wrote: jQuery being what it is, there's bound to be a way of doing this in one line, though :) $(this).addClass(highlight).siblings().removeClass(highlight) ...that saves a document wide search for $(.section) Geoge
[jQuery] Re: Using getScript to load an array of scripts with callbacks
Is that really hard? :( Nazgulled wrote: Anyone? On Feb 22, 6:01 pm, Nazgulled [EMAIL PROTECTED] wrote: I have this piece of code that took me a while to do it and I don't know if it's the best way to achieve this. First, I'll explain exactly what I want to do. I'm using lots of jQuery plugins and I don't want to include them all with script in the head of every html page. And I want to load these plugins for every page that needs them but I don't want to load plugins that some specific page isn't going to need. To load these plugins I'm using the jQuery built-in $.getScript() method and I want to use the callback to load the next script in succession. This way, I'll load one script at a time, meaning, the second script will only start to load when the first finishes and so on. But, when the last plugin finishes loading, I want some other function to be called, in this sample initAdministratio(). Which is basically the function that will start all the required code by my application after all necessary scripts for that page are loaded. On this example, I have 3 plugins to load, and only 2 different pages. One of the plugins is used by both pages, the other two depend on the page to be load. One of the pages has a form with ID = form-login which needs the form plugin, while the other page is the main page and doesn't need the form plugin but needs the color plugin. Although I only have 2 pages on this example, I will probably have more in the future, a lots more. Some of them might need the same plugins as others which will make them fall in the same if() statement, while others don't and I will need to add an else if() statement. The last else statement will always be the default page to load. Meaning, if no specific page was found to load some specific plugins, then, just load the default ones. Now, the code: $.extend($.browser, browserVersion); var loadJSLibs = function(libsList) { var libName = libsList.shift(); var callback = function() { if (libsList.length 0) loadJSLibs(libsList); else initAdministratio(); } $.getScript(libsPath + libName + .js, callback); } if($('div#form-login').length) { var libsList = [ 'jquery.simplemodal', 'jquery.form' ];} else { var libsList = [ 'jquery.simplemodal', 'jquery.colors' ]; } loadJSLibs(libsList) Basically, I want to know if there's anyway to improve this piece of code, somehow. As I've told you before, I took a while to do it as I don't have much JS experience which will probably make me fail to see things that experience JS programmers would not.
[jQuery] Re: How do I use my functions with jQuery syntax alike?
Ok, thanks for all your help... If anyone else can provide any more insight on the differences between those 2 pieces of code... On Feb 23, 2:05 am, timothytoe [EMAIL PROTECTED] wrote: I don't know if there's any practical difference. Maybe someone more knowledgeable can chime it. Perhaps the former ends up being a savings in file size if you have a lot of functions. On Feb 22, 5:44 pm, Nazgulled [EMAIL PROTECTED] wrote: I see, but... How is this: (function($) { $.something = function() { alert('something'); } $.test = { abc: function() { alert('test'); } } })(jQuery); Different from this: jQuery.something = function() { alert('something'); } jQuery.test = { abc: function() { alert('test'); } } Besides the syntax used of course. I mean, you simply do $.something() or $.test.abc() and it will work no matter if you coded in the first way or second... timothytoe wrote: Any time you create a function without a name it's anonymous. Example: window.setTimeout(function() { alert('Hello world!') }, 60); On Feb 22, 4:56 pm, Nazgulled [EMAIL PROTECTED] wrote: timothytoe wrote: The function doesn't have a name, so it doesn't pollute the namespace, and it's great for making functions inline for handlers and setTimeout() without the burden of having to make up a name that won't even be referenced. Can you give me an example of what you mean? I'm getting a bit confused... It's an outgrowth of everything being an object in JavaScript, and being able to pass any object as a parameter. A function is an object in JavaScript and can be passed as a parameter. Yes, I knew that, I just don't see how it relates to anonymous functions. It's very powerful. On Feb 22, 4:39 pm, Nazgulled [EMAIL PROTECTED] wrote: And what exactly it means to hide a function, making it anonymous? timothytoe wrote: JavaScript has really expressive ways to call functions. The first parentheses hide the function (make it anonymous) and the second executes the code immediately with the parameter listed. I'm a newbie myself, but I think that means right now, pass the variable jQuery in as $ to the function and execute the code. On Feb 22, 4:06 pm, Nazgulled [EMAIL PROTECTED] wrote: Thanks... And what's up with the: (function($) { // CODE })(jQuery); This was the thing that got me most confused when reading the documentation. Can someone explain me this, what it does, what is for and the best scenarios where would I need to use something like this? If possible, explain me like I was really dumb :P Klaus Hartl wrote: On Feb 23, 12:14�am, Nazgulled [EMAIL PROTECTED] wrote: Hi, Let's say I have 2 different javascript files. I like to organize my code that's why I use 2 different files so each file will only have functions that fall into that file's category. Anyway, here's the files layout... file1.js: function Fn1() { ... } function Fn2(a, b) { ...} file2.js function FnX(a, b, c) { ... } function FnY(a, b) { ... } function FnZ(a) { ... } How can I call those functions in a syntax like this: $.groupName.Fn1(); $.groupName.Fn2('text', 123); or jQuery.groupName.FnZ(true); How do I do this? P.S: I've read the plugins authoring documentation page but I'm still confused and I don't know how to achieve this, please advise... Something like: $.groupName = $.groupName || {}; $.extend($.groupName, { Fn1: function() { ... }, Fn2: function(a, b) { ... } }); --Klaus
[jQuery] Re: How do I use my functions with jQuery syntax alike?
I bet if you asked on the jQuery development board, you'd get a good answer. The people reading that one are more likely to understand the internals. On Feb 23, 4:59 am, Nazgulled [EMAIL PROTECTED] wrote: Ok, thanks for all your help... If anyone else can provide any more insight on the differences between those 2 pieces of code... On Feb 23, 2:05 am, timothytoe [EMAIL PROTECTED] wrote: I don't know if there's any practical difference. Maybe someone more knowledgeable can chime it. Perhaps the former ends up being a savings in file size if you have a lot of functions. On Feb 22, 5:44 pm, Nazgulled [EMAIL PROTECTED] wrote: I see, but... How is this: (function($) { $.something = function() { alert('something'); } $.test = { abc: function() { alert('test'); } } })(jQuery); Different from this: jQuery.something = function() { alert('something'); } jQuery.test = { abc: function() { alert('test'); } } Besides the syntax used of course. I mean, you simply do $.something() or $.test.abc() and it will work no matter if you coded in the first way or second... timothytoe wrote: Any time you create a function without a name it's anonymous. Example: window.setTimeout(function() { alert('Hello world!') }, 60); On Feb 22, 4:56 pm, Nazgulled [EMAIL PROTECTED] wrote: timothytoe wrote: The function doesn't have a name, so it doesn't pollute the namespace, and it's great for making functions inline for handlers and setTimeout() without the burden of having to make up a name that won't even be referenced. Can you give me an example of what you mean? I'm getting a bit confused... It's an outgrowth of everything being an object in JavaScript, and being able to pass any object as a parameter. A function is an object in JavaScript and can be passed as a parameter. Yes, I knew that, I just don't see how it relates to anonymous functions. It's very powerful. On Feb 22, 4:39 pm, Nazgulled [EMAIL PROTECTED] wrote: And what exactly it means to hide a function, making it anonymous? timothytoe wrote: JavaScript has really expressive ways to call functions. The first parentheses hide the function (make it anonymous) and the second executes the code immediately with the parameter listed. I'm a newbie myself, but I think that means right now, pass the variable jQuery in as $ to the function and execute the code. On Feb 22, 4:06 pm, Nazgulled [EMAIL PROTECTED] wrote: Thanks... And what's up with the: (function($) { // CODE })(jQuery); This was the thing that got me most confused when reading the documentation. Can someone explain me this, what it does, what is for and the best scenarios where would I need to use something like this? If possible, explain me like I was really dumb :P Klaus Hartl wrote: On Feb 23, 12:14�am, Nazgulled [EMAIL PROTECTED] wrote: Hi, Let's say I have 2 different javascript files. I like to organize my code that's why I use 2 different files so each file will only have functions that fall into that file's category. Anyway, here's the files layout... file1.js: function Fn1() { ... } function Fn2(a, b) { ...} file2.js function FnX(a, b, c) { ... } function FnY(a, b) { ... } function FnZ(a) { ... } How can I call those functions in a syntax like this: $.groupName.Fn1(); $.groupName.Fn2('text', 123); or jQuery.groupName.FnZ(true); How do I do this? P.S: I've read the plugins authoring documentation page but I'm still confused and I don't know how to achieve this, please advise... Something like: $.groupName = $.groupName || {}; $.extend($.groupName, { Fn1: function() { ... }, Fn2: function(a, b) { ... } }); --Klaus
[jQuery] Re: Why does it take so long for a new topic to be posted?
That makes sense. But it doesn't negate the fact that 'Google' Groups had funky response yesterday. I hit it several times when 'Google' Groups apologized because the boards were down, and once it came up in what looked like a low-bandwidth version of the 'Google' Groups page. No messages for 15 minutes. Then I grab my coffee and there are dozens of messages in several groups, not just the jQuery ones. On Feb 22, 5:28 pm, Sientz [EMAIL PROTECTED] wrote: On Feb 22, 8:41 am, gh0st [EMAIL PROTECTED] wrote: Why does it take so long for a new topic to be posted? It really is frustrating esp, if you want answers to questions. It has nothing to do with 'Google'. If you look at the link on the right that says 'About This Group' it says something like: Messages By New Members Are Moderated. So basically your topic is sitting there waiting to be authorized by an administrator.
[jQuery] [tooltip] Looping and variable tooltip setup
Greetings, After evaluating several different javascript tooltip libraries I've settled on the jQuery 'Tooltip' plug-in, however I'm having one minor issue getting something working. I'm trying to setup a series of pairs of tooltip triggers/bodies using a generic naming system so that it's easily enable through CGI scripts. To test I have two sets of triggers/bodies that look like this: table tr td div id=tt0Item 1/div div id=tb0 class=tbItem 1's Tooltip/div /td td div id=tt1Item 2/div div id=tb1 class=tbItem 2's Tooltip/div /td /tr /table Where the div with the 'tt?' ids are the tooltip triggers and the 'tb?' ids are the associated tooltip bodies. Now, if for each pair I add the following jQuery script the results are fine: $(function() { $(#tt0).tooltip({bodyHandler: function(){return $ (#tb0).html();}}); $(#tt1).tooltip({bodyHandler: function(){return $ (#tb1).html();}}); }); I get the appropriate tooltip bodies when the mouse hovers over the triggers. The pages that will be generated however will have dozens of tooltips and to have one of these for each would end up causing a lot of overhead in the output, so to alleviate this output overhead I'd like to have a loop that will dynamically perform that. Currently I have the following code: $(function() { var tc = $('[id^=tt]').size(); for (var i = 0; i tc; i++) { var tt = #tt + i; var tb = #tb + i; $(tt).tooltip({bodyHandler: function(){return $ (tb).html();}}); } }); This does create tooltips for the two triggers, however both of them have the tooltip body from 'tb1', I've verified that the values for the 'tt' and 'tb' variables are correct during the loop, and the .text() values from the bodies also show the correct values. Is there something I'm missing from this, or am I going about this the wrong way? I would appreciate any comments or suggestions! Thanks, Derek R.
[jQuery] [validate] Does the validation plugin support required hidden inputs?
Hi, does the validation plugin support required hidden inputs? I have two input fields: field1 (text) and field2 (hidden). When i change the text od field1 a js-function is called and the value of the hidden field2 is changed (or not if the text in field1 is the wrong one). In jquery.validate i have set a rule for field2 (required). When i validate the form and field2 is empty it shows me an error message - that's good! When i change the field1 text (right one now), the field2- value is set but the error message doesn't disappear (because the field2 is hidden and fires no onchange-event). How can i solve this problem? cu rigo
[jQuery] .find does not work in .each
HTML code: div id=catalog_table table tbody tr td id=order/td /tr .. /tbody /table /div JS code: $(#catalog_table TBODY TR).each( function(){ $(this).find(TD[id^='order']).html('TEXT') }); It does not work I try next code: $(#catalog_table TBODY TR TD[id^='order']).each( function(){ $(this).html('TEXT') }); It work fine Why the first JS-code does not work?
[jQuery] Re: Selecting the ancestor of an element
That should do it! Thanks! :) On Feb 22, 4:44 pm, Richard D. Worth [EMAIL PROTECTED] wrote: Then it looks like you want $(childObj).parent().prepend('div id=result_messageResult Processed/div'); That will get you the 1 immediate parent of that element. - Richard On Fri, Feb 22, 2008 at 11:49 AM, AsymF [EMAIL PROTECTED] wrote: If I do the following I end up with every single DIV all the way up the document chain being prepended with the content instead of its immediate parent: var msg_selector = $($(childObj).parent().get(0).tagName + ':has(#' + childObj.id + ')') $(msg_selector).prepend('div id=result_messageResult Processed/ div'); What this is used for is that when a link is clicked it sends AJAX data. If the data was processed remotely it is supposed to show a simple success message at the top of the parent DIV it is located in. Any idea what I am doing wrong? On Feb 22, 6:32 am, Richard D. Worth [EMAIL PROTECTED] wrote: I'm not sure I understand what you're trying to get at. If you have an element (childObj), it has only one parent, $(childObj).parent(). Perhaps you want to provide some more context if I'm not getting it? - Richard On Thu, Feb 21, 2008 at 3:48 PM, AsymF [EMAIL PROTECTED] wrote: How would I select the parent that ONLY has that child? For instance, the following selects too many parents: $($(childObj).parent().get(0).tagName + ':has(#' + childObj.id + ')') On Feb 21, 2:25 pm, Richard D. Worth [EMAIL PROTECTED] wrote: See http://docs.jquery.com/Traversing/parent#expr http://docs.jquery.com/Traversing/parents#expr - Richard On Thu, Feb 21, 2008 at 12:33 PM, AsymF [EMAIL PROTECTED] wrote: How would I select the ancestor or parent of an element?
[jQuery] Re: Call a function just before the window close
Can't put it to work... :( I found an example, but it doesn't work too. Maybe because I'm in firefox, on linux.. don't know. I'm trying the .unload() jquery event now... On Feb 22, 6:27 pm, MorningZ [EMAIL PROTECTED] wrote: there is an onbeforeunload event you can use http://www.google.com/search?q=javascript+onbeforeunloadie=utf-8oe=...
[jQuery] Issue with $.getScript() and $(window).load() - Not working!
Hi, Here's the thing, I'm using the SimpleModal plugin to show a modal dialog on my page. It doesn't really matter which plugin I'm using. Well, I think it doesn't but I haven't actually tested any other plugins in this scenario. When you load any page, the modal dialog will be opened at $ (document).ready(). The idea is to show a modal dialog saying that the page is loading. Then, at $(window).load() I close the modal dialog cause this event will be fired as soon as the page stopped loading. The thing is, this works fine if I load the plugin (the jquery.simplemodal.js file) in the head of the document with a script tag but if I use $.getScript() to load the plugin, it won't work. Well, the modal dialog will be shown, but it won't be closed at $ (window).load(), this is the problem I'm having. And yes, I'm using callbacks with $.getScript() but I don't think it does any good because $(window).load() will actually be called before it should... One last thing, for Firefox, it doesn't matter if I'm loading the plugin in the head or if I'm using $.getScript, it will just work. But on IE7, it only works when the script is loaded in the head. Now, my code is something like this: $(document).ready(function() { $.getScript(jquery.simplemodal.js, function() { $('#simpleModal').modal(); }); }); $(window).load(function() { $.modal.close(); }); Is there in way to fix this? I have no idea how to...
[jQuery] Re: [tooltip] Looping and variable tooltip setup
derek, i haven't thoroughly examined how bodyHandler works but i think something like this should work, provided that your html structure won't change: $('div[id^=tt]').tooltip({ bodyHandler: function(){ return $(this).next().html(); } }); if your html structure will change, you could do something like this: $('div[id^=tt]').tooltip({ bodyHandler: function(){ var id = 'tb' + this.id.substr(2); return $('#'+id).html(); } }); although i'd recommend using classes instead of id's, to avoid cluttering your html (and then using something in the lines of the first example, only instead of $('div[id^=tt]') you could use $('div.tt'), and of course, putting a tt class on the 'item' divs ) .. dennis. derek wrote: Greetings, After evaluating several different javascript tooltip libraries I've settled on the jQuery 'Tooltip' plug-in, however I'm having one minor issue getting something working. I'm trying to setup a series of pairs of tooltip triggers/bodies using a generic naming system so that it's easily enable through CGI scripts. To test I have two sets of triggers/bodies that look like this: table tr td div id=tt0Item 1/div div id=tb0 class=tbItem 1's Tooltip/div /td td div id=tt1Item 2/div div id=tb1 class=tbItem 2's Tooltip/div /td /tr /table Where the div with the 'tt?' ids are the tooltip triggers and the 'tb?' ids are the associated tooltip bodies. Now, if for each pair I add the following jQuery script the results are fine: $(function() { $(#tt0).tooltip({bodyHandler: function(){return $ (#tb0).html();}}); $(#tt1).tooltip({bodyHandler: function(){return $ (#tb1).html();}}); }); I get the appropriate tooltip bodies when the mouse hovers over the triggers. The pages that will be generated however will have dozens of tooltips and to have one of these for each would end up causing a lot of overhead in the output, so to alleviate this output overhead I'd like to have a loop that will dynamically perform that. Currently I have the following code: $(function() { var tc = $('[id^=tt]').size(); for (var i = 0; i tc; i++) { var tt = #tt + i; var tb = #tb + i; $(tt).tooltip({bodyHandler: function(){return $ (tb).html();}}); } }); This does create tooltips for the two triggers, however both of them have the tooltip body from 'tb1', I've verified that the values for the 'tt' and 'tb' variables are correct during the loop, and the .text() values from the bodies also show the correct values. Is there something I'm missing from this, or am I going about this the wrong way? I would appreciate any comments or suggestions! Thanks, Derek R.
[jQuery] Mac OS X default system drag and drop is overriding Interface's drag and drop
Hi all, I'm developing a back end for a photographer's agent, and she wants the site to be mainly drag 'n' drop thumbnail images, so she can create collections of various images, by dragging from various bins. So I've started with a styled ul list of images, and each li contains an img. Each img aligns to the middle of it's li so the whole thing looks like a grid of slides. I'm using the Interface plugin and it's all working great; I can grab the lis and it's easy to re-arrange them. However - with the Mac, when you go to click on the li the browser intercepts the click on the img and thinks you want to drag the image to your desktop! Any functionality gained through Interface is lost. Does anyone have any solutions? I'm going to look at placing some kind of div over the top, but I wanted to ask here first. Cheers, Dave
[jQuery] Re: Mac OS X default system drag and drop is overriding Interface's drag and drop
Thanks, Dave. You just gave me a stomach ache. I just fought the browsers for two days to get my interface working with all the mouseup and mousedown stuff. I eventually got it all working, but only on Windows. I have not tested the Mac browsers yet. I'll be interested in what you come up with. On Feb 23, 9:33 am, Dave Stewart [EMAIL PROTECTED] wrote: Hi all, I'm developing a back end for a photographer's agent, and she wants the site to be mainly drag 'n' drop thumbnail images, so she can create collections of various images, by dragging from various bins. So I've started with a styled ul list of images, and each li contains an img. Each img aligns to the middle of it's li so the whole thing looks like a grid of slides. I'm using the Interface plugin and it's all working great; I can grab the lis and it's easy to re-arrange them. However - with the Mac, when you go to click on the li the browser intercepts the click on the img and thinks you want to drag the image to your desktop! Any functionality gained through Interface is lost. Does anyone have any solutions? I'm going to look at placing some kind of div over the top, but I wanted to ask here first. Cheers, Dave
[jQuery] trying to find the first instance of a person's name on the page
Hello, I am trying to find the first instance of a persons name on a page and add a link to their bio. I have seen a lot of example of selecting elements by their tag/class/ id or finding an element that contains certain text but I am at a loss for finding and wrapping just some text. Is this a RegExp case? Thanks, Stephen
[jQuery] Re: Mac OS X default system drag and drop is overriding Interface's drag and drop
[EMAIL PROTECTED] Macs as usual! was my first thought. But I'm borrowing a Mac laptop to try and check stuff out over the next few days, so I'll try and keep this thread current and will let you know Dave
[jQuery] Re: Mac OS X default system drag and drop is overriding Interface's drag and drop
Yes! The CSS background image is the way forward. Thank [EMAIL PROTECTED] for that. A layered-over-the-top-div solution would have been a complete and horrible hack as far as I'm concerned, so this is just great. li.thumbnail{ position:relative; width:75px; height:75px; float:left; padding:2px; margin:1px; border:1px solid #ccc; background-position:center; background-repeat:no-repeat; list-style:none; } ul li class=thumbnail style=background-image: url(../photographers/ jane_patrick/thumbs/bubble.jpg);/ li class=thumbnail style=background-image: url(../photographers/ jane_patrick/thumbs/Bob_Marchant_3.jpg);/ /ul Hopefully this will help someone else. Cheers, Dave
[jQuery] Re: Mac OS X default system drag and drop is overriding Interface's drag and drop
Brainwave: CSS background-image! I'm going to try this now...
[jQuery] Injecting jQuery with A Bookmarklet
I have a bookmarklet that reads like so... a href=javascript:(function() { var script = document.createElement('script'); script.src = 'http://thinknola.com/files/superduper.js'; document.getElementsByTagName('head')[0].appendChild(script); })(); Super Duper!/a Here is superduper.js SuperDuper = { load: function() { alert('Loaded!'); } }; (function() { var script = document.createElement('script'); script.src = 'http://jquery.com/src/jquery-latest.js'; document.getElementsByTagName('head')[0].appendChild(script); script.onreadystatechange = function () { if (script.readyState == 'complete') { SuperDuper.load(); } } })(); My target platform is Firefox only. It's probably better as a Greasemonkey script, but thought this would be easier. However, I can't figure out how to detect if jquery.js is loaded. What is the equivalent to the above IE code on Firefox? Or should I just poll to see if something like jQuery.fn.each exists? -- Alan Gutierrez | [EMAIL PROTECTED] | http://blogometer.com/ | 504 717 1428 Think New Orleans | http://thinknola.com/
[jQuery] Re: Call a function just before the window close
I couldn't bind 'beforeunload' to the window. document, or body tag successfully. I had to revert to a manual 'window.beforeunload'. I know I should be doing something like evt = window.attachEvent ? window.attachEvent('onbeforeunload', fn) : window.addEventListener('beforeunload', fn, false) but quick and dirty worked for me. If anyone knows how to do it the jQuery bind way, I'm all ears. :D
[jQuery] Re: Call a function just before the window close
Well you know - try as I like, I could NOT get the DOM method addEventListener to work for beforeunload. Doing it the old way: window.onbeforeunload = function(){ return Are you sure? }
[jQuery] Re: Call a function just before the window close
Sorry - text got cut off: Doing it the old way: window.onbeforeunload = function(){ return Are you sure? } Worked great.
[jQuery] Re: trying to find the first instance of a person's name on the page
Well regexp would be useful if there was a pattern to people's names, but there isn't. Do you want to find any names, or a list, or a specific name?
[jQuery] Re: .find does not work in .each
Not sure, but from an id/class point of view, any page id should be unique, so your order identifier if it is to be used on many TDs, should really be a class=order. So if you're just picking up a single id, there's no need to iterate over, is there? Anyway - I replicated your test and find worked fine within each for me.
[jQuery] Re: .find does not work in .each
On Feb 23, 2008, at 2:00 PM, Dave Stewart wrote: Not sure, but from an id/class point of view, any page id should be unique, so your order identifier if it is to be used on many TDs, should really be a class=order. So if you're just picking up a single id, there's no need to iterate over, is there? That's a good point, but it looks like he is trying to find td elements with an id that *starts* with order, so they could be order_1, order_2, etc. I agree, though, that it would be less cumbersome to simply use a common class. Anyway - I replicated your test and find worked fine within each for me. Good to know, since I couldn't see anything wrong with what he was doing. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com
[jQuery] Re: Injecting jQuery with A Bookmarklet
Hi Alan, To test if jQuery exists, you could try: if(typeof jQuery != 'undefined') { // do something } --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Feb 23, 2008, at 1:20 PM, Alan Gutierrez wrote: I have a bookmarklet that reads like so... a href=javascript:(function() { var script = document.createElement('script'); script.src = 'http://thinknola.com/files/superduper.js'; document.getElementsByTagName('head')[0].appendChild(script); })(); Super Duper!/a Here is superduper.js SuperDuper = { load: function() { alert('Loaded!'); } }; (function() { var script = document.createElement('script'); script.src = 'http://jquery.com/src/jquery-latest.js'; document.getElementsByTagName('head')[0].appendChild(script); script.onreadystatechange = function () { if (script.readyState == 'complete') { SuperDuper.load(); } } })(); My target platform is Firefox only. It's probably better as a Greasemonkey script, but thought this would be easier. However, I can't figure out how to detect if jquery.js is loaded. What is the equivalent to the above IE code on Firefox? Or should I just poll to see if something like jQuery.fn.each exists? -- Alan Gutierrez | [EMAIL PROTECTED] | http://blogometer.com/ | 504 717 1428 Think New Orleans | http://thinknola.com/
[jQuery] Re: [tooltip] Looping and variable tooltip setup
dennis, Thanks for the help, both of your examples work great. I also tried substituting in a class 'tt' in place of the individual ids and that seems to work good as well. Is there any speed advantage to this method? I'll probably end up using this method instead as it seems more elegant. Thanks again! Derek R. On Feb 23, 8:16 am, spinnach [EMAIL PROTECTED] wrote: derek, i haven't thoroughly examined how bodyHandler works but i think something like this should work, provided that your html structure won't change: $('div[id^=tt]').tooltip({ bodyHandler: function(){ return $(this).next().html(); } }); if your html structure will change, you could do something like this: $('div[id^=tt]').tooltip({ bodyHandler: function(){ var id = 'tb' + this.id.substr(2); return $('#'+id).html(); } }); although i'd recommend using classes instead of id's, to avoid cluttering your html (and then using something in the lines of the first example, only instead of $('div[id^=tt]') you could use $('div.tt'), and of course, putting a tt class on the 'item' divs ) .. dennis. derek wrote: Greetings, After evaluating several different javascript tooltip libraries I've settled on the jQuery 'Tooltip' plug-in, however I'm having one minor issue getting something working. I'm trying to setup a series of pairs of tooltip triggers/bodies using a generic naming system so that it's easily enable through CGI scripts. To test I have two sets of triggers/bodies that look like this: table tr td div id=tt0Item 1/div div id=tb0 class=tbItem 1's Tooltip/div /td td div id=tt1Item 2/div div id=tb1 class=tbItem 2's Tooltip/div /td /tr /table Where the div with the 'tt?' ids are the tooltip triggers and the 'tb?' ids are the associated tooltip bodies. Now, if for each pair I add the following jQuery script the results are fine: $(function() { $(#tt0).tooltip({bodyHandler: function(){return $ (#tb0).html();}}); $(#tt1).tooltip({bodyHandler: function(){return $ (#tb1).html();}}); }); I get the appropriate tooltip bodies when the mouse hovers over the triggers. The pages that will be generated however will have dozens of tooltips and to have one of these for each would end up causing a lot of overhead in the output, so to alleviate this output overhead I'd like to have a loop that will dynamically perform that. Currently I have the following code: $(function() { var tc = $('[id^=tt]').size(); for (var i = 0; i tc; i++) { var tt = #tt + i; var tb = #tb + i; $(tt).tooltip({bodyHandler: function(){return $ (tb).html();}}); } }); This does create tooltips for the two triggers, however both of them have the tooltip body from 'tb1', I've verified that the values for the 'tt' and 'tb' variables are correct during the loop, and the .text() values from the bodies also show the correct values. Is there something I'm missing from this, or am I going about this the wrong way? I would appreciate any comments or suggestions! Thanks, Derek R.
[jQuery] Re: JQuery site is blank for one user
Thanks Shawn. I'm awaiting the user's feedback on the points you raised. rgds, Andrew
[jQuery] How to select an element based on visibility
Hi,I cannot get my finger behind this one: I have this HTML: p class=firstLineThis is the first line of the first paragraph/p pAnd here is some more text. Bladibladibla/p p class=firstLineThis is the first line of the secons paragraph/ p pAnd here is some more text. Bladibladibla/p p class=firstLineThis is the first line of the third paragraph/p pAnd here is some more text. Bladibladibla/p when I click a p class firstLine, I want the paragraph immediately _below_ it to disappear if it is visible. If it is invisible, I want it to show again. This $(document).ready(function(){ $(.firstLine).click(function(){ var el = $(this).next(); $(el:hidden).click.slideDown(slow); $(el:visible).click.slideup(slow); }); }); doesn't work. How can I do this? Thanks
[jQuery] Re: [tooltip] Looping and variable tooltip setup
derek, i'm not sure if there are any speed advantages (in both cases jquery has to loop through all divs on the page to find the ones you need - either by class or by id, so there probably is none) but by using classes your keeping your html cleaner.. as a rule, things that repeat on a page or through out the site, and have the same purpose, should use classes, and things which are specific and more important should use id's.. or at least, that's the how i do it :).. dennis. derek wrote: dennis, Thanks for the help, both of your examples work great. I also tried substituting in a class 'tt' in place of the individual ids and that seems to work good as well. Is there any speed advantage to this method? I'll probably end up using this method instead as it seems more elegant. Thanks again! Derek R. On Feb 23, 8:16 am, spinnach [EMAIL PROTECTED] wrote: derek, i haven't thoroughly examined how bodyHandler works but i think something like this should work, provided that your html structure won't change: $('div[id^=tt]').tooltip({ bodyHandler: function(){ return $(this).next().html(); } }); if your html structure will change, you could do something like this: $('div[id^=tt]').tooltip({ bodyHandler: function(){ var id = 'tb' + this.id.substr(2); return $('#'+id).html(); } }); although i'd recommend using classes instead of id's, to avoid cluttering your html (and then using something in the lines of the first example, only instead of $('div[id^=tt]') you could use $('div.tt'), and of course, putting a tt class on the 'item' divs ) .. dennis. derek wrote: Greetings, After evaluating several different javascript tooltip libraries I've settled on the jQuery 'Tooltip' plug-in, however I'm having one minor issue getting something working. I'm trying to setup a series of pairs of tooltip triggers/bodies using a generic naming system so that it's easily enable through CGI scripts. To test I have two sets of triggers/bodies that look like this: table tr td div id=tt0Item 1/div div id=tb0 class=tbItem 1's Tooltip/div /td td div id=tt1Item 2/div div id=tb1 class=tbItem 2's Tooltip/div /td /tr /table Where the div with the 'tt?' ids are the tooltip triggers and the 'tb?' ids are the associated tooltip bodies. Now, if for each pair I add the following jQuery script the results are fine: $(function() { $(#tt0).tooltip({bodyHandler: function(){return $ (#tb0).html();}}); $(#tt1).tooltip({bodyHandler: function(){return $ (#tb1).html();}}); }); I get the appropriate tooltip bodies when the mouse hovers over the triggers. The pages that will be generated however will have dozens of tooltips and to have one of these for each would end up causing a lot of overhead in the output, so to alleviate this output overhead I'd like to have a loop that will dynamically perform that. Currently I have the following code: $(function() { var tc = $('[id^=tt]').size(); for (var i = 0; i tc; i++) { var tt = #tt + i; var tb = #tb + i; $(tt).tooltip({bodyHandler: function(){return $ (tb).html();}}); } }); This does create tooltips for the two triggers, however both of them have the tooltip body from 'tb1', I've verified that the values for the 'tt' and 'tb' variables are correct during the loop, and the .text() values from the bodies also show the correct values. Is there something I'm missing from this, or am I going about this the wrong way? I would appreciate any comments or suggestions! Thanks, Derek R.
[jQuery] Re: trying to find the first instance of a person's name on the page
Hi Dave, I want to find specific names (I have a list of 320 names in an xml file). I want to scan through a page and create a link around the first instance for one of the names in the list. eg Stephen Boyd's favourite person in the work is Fred Von Brown. Stephen Boyd calls Fred Von Brown every day. would become a href=biolinkStephenStephen Boyd's/a favourite person in the work is a href=biolinkFredFred Von Brown/a. Stephen Boyd calls Fred Von Brown every day. One of the gotcha's I've considered is that some people's names may have apostrophes on them, eg Stephen Boyd's. I'm sure there are many more gotcha's as well but at this point I am trying to get a sense of the feasibility of this idea. On Feb 23, 1:48 pm, Dave Stewart [EMAIL PROTECTED] wrote: Well regexp would be useful if there was a pattern to people's names, but there isn't. Do you want to find any names, or a list, or a specific name?
[jQuery] Re: trying to find the first instance of a person's name on the page
Do you know the list of names? Or are you trying to identify what might be a name on the page (say two words in a row with initial caps)? On Feb 23, 12:35 pm, sspboyd [EMAIL PROTECTED] wrote: Hi Dave, I want to find specific names (I have a list of 320 names in an xml file). I want to scan through a page and create a link around the first instance for one of the names in the list. eg Stephen Boyd's favourite person in the work is Fred Von Brown. Stephen Boyd calls Fred Von Brown every day. would become a href=biolinkStephenStephen Boyd's/a favourite person in the work is a href=biolinkFredFred Von Brown/a. Stephen Boyd calls Fred Von Brown every day. One of the gotcha's I've considered is that some people's names may have apostrophes on them, eg Stephen Boyd's. I'm sure there are many more gotcha's as well but at this point I am trying to get a sense of the feasibility of this idea. On Feb 23, 1:48 pm, Dave Stewart [EMAIL PROTECTED] wrote: Well regexp would be useful if there was a pattern to people's names, but there isn't. Do you want to find any names, or a list, or a specific name?
[jQuery] Re: .find does not work in .each
it looks like he is trying to find td elements with an id that *starts* with order, True! But the jquery was good. So not sure what was going on there. Sometimes you just need to delete blocks of code and write from scratch, as you just can't what's not quite right (the brain sees what it wants to!). Maybe this is one of those times!
[jQuery] Re: How to select an element based on visibility
You're very close. The .slideToggle() method will slide down if hidden and up if visible: $(document).ready(function(){ $(.firstLine).click(function(){ $(this).next().slideToggle('slow'); }); }); Working with your code the way you had it, you could have done something like this: $(document).ready(function(){ $(.firstLine).click(function(){ var el = $(this).next(); if (el.is(:hidden)) { el.slideDown(slow); } else { el..slideup(slow); } }); }); You could also use a ternary operator to abbreviate the code a bit: $(document).ready(function(){ $(.firstLine).click(function(){ var el = $(this).next(); el[el.is(:hidden) ? slideDown : slideUp](slow); }); }); Hope that helps. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Feb 23, 2008, at 12:28 PM, zephyr wrote: Hi,I cannot get my finger behind this one: I have this HTML: p class=firstLineThis is the first line of the first paragraph/p pAnd here is some more text. Bladibladibla/p p class=firstLineThis is the first line of the secons paragraph/ p pAnd here is some more text. Bladibladibla/p p class=firstLineThis is the first line of the third paragraph/p pAnd here is some more text. Bladibladibla/p when I click a p class firstLine, I want the paragraph immediately _below_ it to disappear if it is visible. If it is invisible, I want it to show again. This $(document).ready(function(){ $(.firstLine).click(function(){ var el = $(this).next(); $(el:hidden).click.slideDown(slow); $(el:visible).click.slideup(slow); }); }); doesn't work. How can I do this? Thanks
[jQuery] Re: How to select an element based on visibility
el.click(function(){ $(this).slideToggle('slow'); }); On Feb 24, 1:28 am, zephyr [EMAIL PROTECTED] wrote: Hi,I cannot get my finger behind this one: I have this HTML: p class=firstLineThis is the first line of the first paragraph/p pAnd here is some more text. Bladibladibla/p p class=firstLineThis is the first line of the secons paragraph/ p pAnd here is some more text. Bladibladibla/p p class=firstLineThis is the first line of the third paragraph/p pAnd here is some more text. Bladibladibla/p when I click a p class firstLine, I want the paragraph immediately _below_ it to disappear if it is visible. If it is invisible, I want it to show again. This $(document).ready(function(){ $(.firstLine).click(function(){ var el = $(this).next(); $(el:hidden).click.slideDown(slow); $(el:visible).click.slideup(slow); }); }); doesn't work. How can I do this? Thanks
[jQuery] Re: trying to find the first instance of a person's name on the page
Timothy, Yes, I know the list of names. On Feb 23, 3:41 pm, timothytoe [EMAIL PROTECTED] wrote: Do you know the list of names? Or are you trying to identify what might be a name on the page (say two words in a row with initial caps)? On Feb 23, 12:35 pm, sspboyd [EMAIL PROTECTED] wrote: Hi Dave, I want to find specific names (I have a list of 320 names in an xml file). I want to scan through a page and create a link around the first instance for one of the names in the list. eg Stephen Boyd's favourite person in the work is Fred Von Brown. Stephen Boyd calls Fred Von Brown every day. would become a href=biolinkStephenStephen Boyd's/a favourite person in the work is a href=biolinkFredFred Von Brown/a. Stephen Boyd calls Fred Von Brown every day. One of the gotcha's I've considered is that some people's names may have apostrophes on them, eg Stephen Boyd's. I'm sure there are many more gotcha's as well but at this point I am trying to get a sense of the feasibility of this idea. On Feb 23, 1:48 pm, Dave Stewart [EMAIL PROTECTED] wrote: Well regexp would be useful if there was a pattern to people's names, but there isn't. Do you want to find any names, or a list, or a specific name?
[jQuery] unbind LocalScroll?
Wondering if anyone can help me with the LocalScroll plugin: I'm using the LocalScroll plugin and would like to programmatically unbind it from the nav links and target so that I can modify the set of links and the target, then rebind it. I tried using the lazy:true setting, but I found that I was not able to programmatically fire .click() events on the nav links (which I'm doing for some custom next/prev stuff) when lazy = true. I'm thinking that if I can unbind it, then rebind it, what I'm trying to do will work. The functionality is a set of links/target that change after someone logs in (the login is performed via ajax, so the page does not reload). If not unbinding/rebinding, maybe there's another/better way? Thanks, Jack
[jQuery] Re: trying to find the first instance of a person's name on the page
Well you could do something like this (it would be prohibitively slow on 250 names on one page though!!) : var names = ['Stephen','Fred'] $(body).each( function(){ var html = $(this).html() $(names).each( function(i, e){ var rx= new RegExp(e, 'gi') html = html.replace(rx, 'b style=color:red' +e+ '/ b') } ) $(this).html(html) } ) If you want to check this out on this page, load jQuery using my jQuery Favelet... http://www.keyframesandcode.com/code/development/javascript/jquery-favelet/ ...then copy / paste the code into Firebug and run it there.
[jQuery] Re: trying to find the first instance of a person's name on the page
For only the first name on each page, just remove the 'g' modifier from the RegExp constructor (I'm sure you know this)
[jQuery] Re: trying to find the first instance of a person's name on the page
Heh heh, this is cool! var names = ['Stephen Boyd','Fred Von Brown'] $(body).each( function(){ var html = $(this).html() $(names).each( function(i, e){ var rx= new RegExp(e, 'gi') html = html.replace(rx, 'a href=javascript:void(0); onclick=alert(this.innerHTML)' +e+ '/a') } ) $(this).html(html) } )
[jQuery] jQuery is killing my xhtml strict validation
Not sure this is 100% jQuery's problem. I do this: $(#logo).html(img src='images/logosmall.gif' alt='logopic' /); But what lands in the browser is this: div id=logoimg src=images/logosmall.gif alt=logopic/div Interestingly, the single quotes have been converted to double quotes and the trailing / has been lost, which kills my validation. Is it jQuery being funny here or the browser itself? What should I do? If it helps, my PHP file stats like this: !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; head meta name=generator content=HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org /
[jQuery] Re: Browser.Version for IE7 Vista returned as 6
Try this: $.browser.msie6 = $.browser.msie /MSIE 6\.0/i.test(window.navigator.userAgent) !/MSIE 7\.0/i.test(window.navigator.userAgent); So far as I know the problem with Vista IE7 is that it contains both strings. So actual IE6 would NOT contain the MSIE 7.0 string. JK -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of MichaelEvangelista Sent: Friday, February 22, 2008 8:09 PM To: jQuery (English) Subject: [jQuery] Browser.Version for IE7 Vista returned as 6 I am trying to eliminate some width-related effects in IE6 but leave them intact for 7 - however, browser.version returns IE7 as 6.0, and I cannot find a way to differentiate the two. I am aware this is a known issue, but I haven't found a fix that works. Does anybody have a working solution they'd be willing to share (or have already posted somewhere?) thanks very much
[jQuery] Firefox 3 (contentEdiable / execCommand).
Hay all, Firefox 3 as support for contentEditable. This is great and all, but i have a huge error. http://kevin-ruscoe.plesk3.freepgs.com/contenteditable/ I cannot run execCommand() on my text, this works in safari and IE6+ I found the reason why this happens. When i click the anchor tag, the DIV loses focus and the nothing is selected. I need to know how to to re-select the selection then do the execCommand. Thanks all :)
[jQuery] jquery form plugin submitting for multiple times after DOM is appended
I'm using the jquery form plugin from a form which is retrieved via ajax. I have multiple forms on the page. I'm using .livequery to make sure the form is only requested once, but didn't realize my problem is that the submit is actually occuring more than once. I've tried adding .livequery to the begging of the .submit function so that it would hopefully only be triggered once, but that hasn't worked for me. I would prefer to not do an 'unbind/bind' function because with cancelling of the form, etc. it gets a bit complicated. Is there a simple way to do this? Here is the code I have to call the form and then to submit it. This code includes my attempt to use livequery in this, but the form still submits multiple times. [code] $(.addGroup).livequery('click', function(event) { id = this.id; var posTop = event.pageY; var posLeft = event.pageX; var formID = #createForm; $.ajax({ type: GET, url: processes/addType.php, data: gid=+id, success: function(response){ $(formID).css({ position: 'absolute', top: posTop, left: posLeft }); $(formID).fadeIn(slow).html(response); $(#createForm).livequery('click', function(){ addShiftAJAX(); }); cancelForm(formID); templateShifts(); } }); }); // prepare the form when the DOM is ready function addAJAX(){ var options = { target:'#createForm', // target element(s) to be updated with server response success: showResponse }; // bind to the form's submit event $('#createForm').submit(function() { // inside event callbacks 'this' is the DOM element so we first // wrap it in a jQuery object and then invoke ajaxSubmit $(this).ajaxSubmit(options); // !!! Important !!! // always return false to prevent standard browser submit and page navigation return false; }); // pre-submit callback function showRequest(formData, jqForm, options) { // formData is an array; here we use $.param to convert it to a string to display it // but the form plugin does this for you automatically when it submits the data var queryString = $.param(formData); // jqForm is a jQuery object encapsulating the form element. To access the // DOM element for the form do this: // var formElement = jqForm[0]; alert('About to submit: \n\n' + queryString); // here we could return false to prevent the form from being submitted; // returning anything other than false will allow the form submit to continue } // post-submit callback function showResponse(options) { // for normal html responses, the first argument to the success callback // is the XMLHttpRequest object's responseText property // if the ajaxSubmit method was passed an Options Object with the dataType // property set to 'xml' then the first argument to the success callback // is the XMLHttpRequest object's responseXML property // if the ajaxSubmit method was passed an Options Object with the dataType // property set to 'json' then the first argument to the success callback // is the json data object returned by the server $.ajax({ type: GET, url: processes/getGroups.php, data: cid=+cid, success: function(response2){ $(.groups).html(response2); $(#createForm).fadeOut(slow); } }); }; }; [/code]
[jQuery] Re: How to select an element based on visibility
Thanks Karl, this works. Very instructive - didn't know the syntax of the is and ternary operator in jQuery. I'll check out learningjquery! Marc
[jQuery] livequery, $.ajax and json
Hello, I have this code: $('input#add_imageupload').livequery('click', function(){ var image = $('input#add_image').val(); alert(image); $.ajax({ type: POST, dataType: html, url: albums.php, data: image=+image, success: function() { alert('works'); } }); }); I have to use livequery, because I'm loading new data into new fields etc etc. The current example should work, but if I change dataType to json, it stops and I don't know why? Any ideas? Are there any problems with livequery and json?
[jQuery] jqModal - how to call jquery functions on returned AHAH?
Hi, I'm using jqModal:ajax to load a remote php into a div modal form. So far so good. But the returned HTML also has some jquery elements. I can't figure out how to get them to initialize (i.e. the function call that would otherwise be in the $(document).ready function). I tried doing something with onload like so: script $().ready(function() { $('#ex2').jqm({ ajax: 'prodtabs2.php', trigger:'a.ex2trigger', onLoad: loadAjax }); }); var loadAjax = function(jqmHash) { $(#productinfo ul).tabs(); // trying to init jquery.ui.tabs }; /script I also tried using jqmHash.w as a second parameter, but also to no avail. Can anyone point me in the right direction? Thanks. -- View this message in context: http://www.nabble.com/jqModal---how-to-call-jquery-functions-on-returned-AHAH--tp15657058s27240p15657058.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: Using getScript to load an array of scripts with callbacks
As you might already know, there is a nice plugin you can find at http://www.creativit.com.br/jquery/ondemand_js/index.htm play with it... you maybe end up understanding a litte more on dinamic script loading. But my question remains: As native $.getScript() documentation noticed(Warning: Safari 2 and older is unable to evaluate scripts in a global context synchronously. If you load functions via getScript, make sure to call them after a delay.) , there is an issue when dynamic loading scripts on Safari 2 and older. Has someone worked- around it to have a cross-browser fashion to have a callback without using a delay? Iair. On 23 feb, 10:59, Nazgulled [EMAIL PROTECTED] wrote: Is that really hard? :( Nazgulled wrote: Anyone? On Feb 22, 6:01 pm, Nazgulled [EMAIL PROTECTED] wrote: I have this piece of code that took me a while to do it and I don't know if it's the best way to achieve this. First, I'll explain exactly what I want to do. I'm using lots of jQuery plugins and I don't want to include them all with script in the head of every html page. And I want to load these plugins for every page that needs them but I don't want to load plugins that some specific page isn't going to need. To load these plugins I'm using the jQuery built-in $.getScript() method and I want to use the callback to load the next script in succession. This way, I'll load one script at a time, meaning, the second script will only start to load when the first finishes and so on. But, when the last plugin finishes loading, I want some other function to be called, in this sample initAdministratio(). Which is basically the function that will start all the required code by my application after all necessary scripts for that page are loaded. On this example, I have 3 plugins to load, and only 2 different pages. One of the plugins is used by both pages, the other two depend on the page to be load. One of the pages has a form with ID = form-login which needs the form plugin, while the other page is the main page and doesn't need the form plugin but needs the color plugin. Although I only have 2 pages on this example, I will probably have more in the future, a lots more. Some of them might need the same plugins as others which will make them fall in the same if() statement, while others don't and I will need to add an else if() statement. The last else statement will always be the default page to load. Meaning, if no specific page was found to load some specific plugins, then, just load the default ones. Now, the code: $.extend($.browser, browserVersion); var loadJSLibs = function(libsList) { var libName = libsList.shift(); var callback = function() { if (libsList.length 0) loadJSLibs(libsList); else initAdministratio(); } $.getScript(libsPath + libName + .js, callback); } if($('div#form-login').length) { var libsList = [ 'jquery.simplemodal', 'jquery.form' ];} else { var libsList = [ 'jquery.simplemodal', 'jquery.colors' ]; } loadJSLibs(libsList) Basically, I want to know if there's anyway to improve this piece of code, somehow. As I've told you before, I took a while to do it as I don't have much JS experience which will probably make me fail to see things that experience JS programmers would not.
[jQuery] Re: jQuery is killing my xhtml strict validation
Try !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; And XHTML mandates the use of quotation marks not apostrophe's which is probly why its getting converted ~ Big Dog timothytoe wrote: Not sure this is 100% jQuery's problem. I do this: $(#logo).html(img src='images/logosmall.gif' alt='logopic' /); But what lands in the browser is this: div id=logoimg src=images/logosmall.gif alt=logopic/div Interestingly, the single quotes have been converted to double quotes and the trailing / has been lost, which kills my validation. Is it jQuery being funny here or the browser itself? What should I do? If it helps, my PHP file stats like this: !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; head meta name=generator content=HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org /
[jQuery] Re: refreshing a div tag
Steve, I searched around the web a bit for a way to refresh a div tag at set intervals but haven't found anything that pertains to jquery. I saw some stuff about prototype and ColdFusion 8, neither of which were any help. Does anyone have a preferred method of doing this? I'd like to be able to have the div tag refresh at regular intervals and also be triggered by clicking a link or triggering an event. There's a plug-in called Heartbeat you can use repeat an AJAX operation at set interval. To trigger an update manually (via a click event or programmatically) you can use the $.ajax() method. -dan
[jQuery] Re: IE/Opera problem using ClueTip
Hi Faraz, I think the problem must have something to do with your server configuration. I posted your files on my server and it looks like it's working fine in Opera (tried your link, and it was asking for the user name / password). Check it out: http://test.learningjquery.com/faraz/Tooltip.html --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Feb 23, 2008, at 3:14 PM, fshuja wrote: btw, i want to create the same tooltip as on http://www.netflix.com/BrowseSelection
[jQuery] Re: unbind LocalScroll?
Hi Jack I haven't added a way to cleanly unbind localScroll as I didn't thought it would be usual. If that's the case, I can tell you what element to call unbind on. jQuery.LocalScroll is prepared to handle dynamic content. That's why the option lazy is there. If you choose the lazy option, then event delegation is used. That means that if you do: $ (something).localScroll({lazy:true,..}). The binding is done on that 'something'. And as long as you preserve it, the click on links will still be caught, if you don't understand what I mean, check the AJAX demo. The links are renewed on each load and no rebinding is needed. If you need any more help, mail me to aflesler(at)gmail(dot)com and I'll help you out. Cheers Ariel Flesler On 23 feb, 18:59, Jack Killpatrick [EMAIL PROTECTED] wrote: Wondering if anyone can help me with the LocalScroll plugin: I'm using the LocalScroll plugin and would like to programmatically unbind it from the nav links and target so that I can modify the set of links and the target, then rebind it. I tried using the lazy:true setting, but I found that I was not able to programmatically fire .click() events on the nav links (which I'm doing for some custom next/prev stuff) when lazy = true. I'm thinking that if I can unbind it, then rebind it, what I'm trying to do will work. The functionality is a set of links/target that change after someone logs in (the login is performed via ajax, so the page does not reload). If not unbinding/rebinding, maybe there's another/better way? Thanks, Jack
[jQuery] Re: jQuery is killing my xhtml strict validation
It's not a problem. I assume you're viewing the DOM tree via Firebug (or something similar)? If so then what you're seeing is a representation of the tree that Firebug is generating. The concept of XHTML vs HTML (vs XML) is pretty much gone after the (X)HTML is parsed and turned into the DOM tree. There's no need for keeping around the quotes, '/' or other delimiters as each of the elements now exists as a node, not as some textual representation. Karl Rudd On Sun, Feb 24, 2008 at 10:52 AM, timothytoe [EMAIL PROTECTED] wrote: Not sure this is 100% jQuery's problem. I do this: $(#logo).html(img src='images/logosmall.gif' alt='logopic' /); But what lands in the browser is this: div id=logoimg src=images/logosmall.gif alt=logopic/div Interestingly, the single quotes have been converted to double quotes and the trailing / has been lost, which kills my validation. Is it jQuery being funny here or the browser itself? What should I do? If it helps, my PHP file stats like this: !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; head meta name=generator content=HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org /
[jQuery] Re: Using getScript to load an array of scripts with callbacks
As much as I appreciate your input and with all due respect, I didn't ask for a plugin to import JS files. I asked about the code I posted and if there is a way to improve it. I'm new to jQuery and Javascript itself and as I took lots of time to do that tiny piece of code I just thought that it may have something wrong with it and can easily be improved by someone more knowledgeable than myself... On Feb 24, 12:48 am, Iair Salem [EMAIL PROTECTED] wrote: As you might already know, there is a nice plugin you can find at http://www.creativit.com.br/jquery/ondemand_js/index.htm play with it... you maybe end up understanding a litte more on dinamic script loading. But my question remains: As native $.getScript() documentation noticed(Warning: Safari 2 and older is unable to evaluate scripts in a global context synchronously. If you load functions via getScript, make sure to call them after a delay.) , there is an issue when dynamic loading scripts on Safari 2 and older. Has someone worked- around it to have a cross-browser fashion to have a callback without using a delay? Iair. On 23 feb, 10:59, Nazgulled [EMAIL PROTECTED] wrote: Is that really hard? :( Nazgulled wrote: Anyone? On Feb 22, 6:01 pm, Nazgulled [EMAIL PROTECTED] wrote: I have this piece of code that took me a while to do it and I don't know if it's the best way to achieve this. First, I'll explain exactly what I want to do. I'm using lots of jQuery plugins and I don't want to include them all with script in the head of every html page. And I want to load these plugins for every page that needs them but I don't want to load plugins that some specific page isn't going to need. To load these plugins I'm using the jQuery built-in $.getScript() method and I want to use the callback to load the next script in succession. This way, I'll load one script at a time, meaning, the second script will only start to load when the first finishes and so on. But, when the last plugin finishes loading, I want some other function to be called, in this sample initAdministratio(). Which is basically the function that will start all the required code by my application after all necessary scripts for that page are loaded. On this example, I have 3 plugins to load, and only 2 different pages. One of the plugins is used by both pages, the other two depend on the page to be load. One of the pages has a form with ID = form-login which needs the form plugin, while the other page is the main page and doesn't need the form plugin but needs the color plugin. Although I only have 2 pages on this example, I will probably have more in the future, a lots more. Some of them might need the same plugins as others which will make them fall in the same if() statement, while others don't and I will need to add an else if() statement. The last else statement will always be the default page to load. Meaning, if no specific page was found to load some specific plugins, then, just load the default ones. Now, the code: $.extend($.browser, browserVersion); var loadJSLibs = function(libsList) { var libName = libsList.shift(); var callback = function() { if (libsList.length 0) loadJSLibs(libsList); else initAdministratio(); } $.getScript(libsPath + libName + .js, callback); } if($('div#form-login').length) { var libsList = [ 'jquery.simplemodal', 'jquery.form' ];} else { var libsList = [ 'jquery.simplemodal', 'jquery.colors' ]; } loadJSLibs(libsList) Basically, I want to know if there's anyway to improve this piece of code, somehow. As I've told you before, I took a while to do it as I don't have much JS experience which will probably make me fail to see things that experience JS programmers would not.
[jQuery] Re: unbind LocalScroll?
Also.. you mentioned prev/next links. Maybe what you need is SerialScroll: http://flesler.blogspot.com/2008/02/jqueryserialscroll.html It's pretty similar to LocalScroll, it also has a 'lazy' option, but it's meant to be used for prev/next situations. Ariel Flesler On 23 feb, 23:12, Ariel Flesler [EMAIL PROTECTED] wrote: Hi Jack I haven't added a way to cleanly unbind localScroll as I didn't thought it would be usual. If that's the case, I can tell you what element to call unbind on. jQuery.LocalScroll is prepared to handle dynamic content. That's why the option lazy is there. If you choose the lazy option, then event delegation is used. That means that if you do: $ (something).localScroll({lazy:true,..}). The binding is done on that 'something'. And as long as you preserve it, the click on links will still be caught, if you don't understand what I mean, check the AJAX demo. The links are renewed on each load and no rebinding is needed. If you need any more help, mail me to aflesler(at)gmail(dot)com and I'll help you out. Cheers Ariel Flesler On 23 feb, 18:59, Jack Killpatrick [EMAIL PROTECTED] wrote: Wondering if anyone can help me with the LocalScroll plugin: I'm using the LocalScroll plugin and would like to programmatically unbind it from the nav links and target so that I can modify the set of links and the target, then rebind it. I tried using the lazy:true setting, but I found that I was not able to programmatically fire .click() events on the nav links (which I'm doing for some custom next/prev stuff) when lazy = true. I'm thinking that if I can unbind it, then rebind it, what I'm trying to do will work. The functionality is a set of links/target that change after someone logs in (the login is performed via ajax, so the page does not reload). If not unbinding/rebinding, maybe there's another/better way? Thanks, Jack- Ocultar texto de la cita - - Mostrar texto de la cita -
[jQuery] Re: jQuery is killing my xhtml strict validation
OK. Since I'm creating so much of the web site on the fly, there's really no way of knowing whether I'm valid or not, is there? I mean it's pretty easy to make my trivial, skeletal html (or php) file valid--there's hardly anything in it! I tried to go through all the paths and validate. I guess I'm OK if all I get are warnings that complain about the validator seeing an HTML version of the DOM rather than a XHTML version. Oh, and canvas is not valid. Nothing to be done about that, right? On Feb 23, 6:36 pm, Karl Rudd [EMAIL PROTECTED] wrote: It's not a problem. I assume you're viewing the DOM tree via Firebug (or something similar)? If so then what you're seeing is a representation of the tree that Firebug is generating. The concept of XHTML vs HTML (vs XML) is pretty much gone after the (X)HTML is parsed and turned into the DOM tree. There's no need for keeping around the quotes, '/' or other delimiters as each of the elements now exists as a node, not as some textual representation. Karl Rudd On Sun, Feb 24, 2008 at 10:52 AM, timothytoe [EMAIL PROTECTED] wrote: Not sure this is 100% jQuery's problem. I do this: $(#logo).html(img src='images/logosmall.gif' alt='logopic' /); But what lands in the browser is this: div id=logoimg src=images/logosmall.gif alt=logopic/div Interestingly, the single quotes have been converted to double quotes and the trailing / has been lost, which kills my validation. Is it jQuery being funny here or the browser itself? What should I do? If it helps, my PHP file stats like this: !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; head meta name=generator content=HTML Tidy for Linux/x86 (vers 11 February 2007), seewww.w3.org /
[jQuery] Little problem with ajax perhaps?
Hi, I'm using the jQuery form plugin and SimpleModal plugin and I'm having a little problem that I don't understand why it's happening. As my understanding in the whole thing, this shouldn't be happening and I can't understand why. The thing is, I show a blue popup while the page is loading, it shows on document ready and it hides on window load. Then, you submit a form and the form is submitted by ajax so there is a request and response. On the request I show a blue popup saying the form is submitted and it remains there until the server responds and the ajax response is fired, when it does, the popup will be red and show an error message (when there are errors of course). Then, we close the popup manually. Then, you click refresh or leave the page, I also added the same popup saying the page is loading, this I've done on window onbeforeunload. Now, the problem is on the last popup described. For all the popups (the html elements are the same) I simply swap css colors and content of the elements when needed. However, for the last popup, I didn't change anything and my best guess is that it should have remained with the colors from the error popup and it's message cause it was the last on to be show and so, the html elements have the properties from the las popup. However, the popup is blue and it shows the text messages from the popup that is displayed on the ajax request. Ok, this might sound a little confused so I built a demo that you can take a look here: http://nazgulled.clok.info/test/admin/ It's filled with alert()'s along the way to explain what's happening and where is the problem. Just view the source code of the page, everything is inline (besides the jQuery lib and it's plugins). Please help me out on this, I need to understand why this is happening so I can continue my project and develop it accordingly...