Re: [jQuery] Sound
No jQuery necessarily needed for this. Plenty of information here: http://www.google.com/search?q=html+embed+audio --Erik On Thu, Nov 5, 2009 at 3:04 PM, shapper mdmo...@gmail.com wrote: Hello, Is it possible to have a music on a HTML page with two buttons to play/ stop? Can I use JQuery for this? Thanks, Miguel
Spam increase (WAS: Re: [jQuery] Re: XXX hot sexy banned movie XXX)
Some of my servers are seeing a lot more DDoS type traffic and I'm seeing a lot more spam across all of the mailing lists that I'm on. It's seeming like something is going on. --Erik On Tue, Sep 29, 2009 at 4:09 PM, Mike Alsup mal...@gmail.com wrote: Sigh.. this message was *not* sent by me. And I've just changed my Google password so hopefully it won't happen again. Mike On Sep 30, 6:24 am, mal...@gmail.com mal...@gmail.com wrote: hot sexy banned movie
[jQuery] Re: Synchronous call in JQuery?
Your question doesn't make very much sense. In your example, doSomething2 would execute after doSomething1 finished, so it is synchronous. Perhaps you could provide an example of what you're actually trying to do? --Erik On Mon, Sep 28, 2009 at 6:24 AM, Mesquite koen.buekenh...@gmail.com wrote: Is there a JQuery way to execute a custom function 'after' another custom function is executed? The second function must wait until the first one has finished. (Not asynchronous but synchronous) Important: I don't want place the call to the second function in the first one. for example: doSomething1(); doSomething2(); function doSomething1() { } function doSomething2() { }
[jQuery] Re: Web Application GUI's
I do 2 kinds of webapps: very rich (or heavy) desktop-replacement type apps, for which I generally use EXT, and much lighter, javascript-optional type websites, for which I generally buy a template from ThemeForrest. --Erik On Fri, Aug 14, 2009 at 1:15 PM, Meroe whme...@gmail.com wrote: Hello all, I assume I'm like many of you. I'm able to write code, but when it comes to design I am at a loss. I've seen some really neat layouts such as mochaui and extjs examples, but I'm struggling to put together one I'm happy with. I'm using the jquery UI layout to set up my north, west, east, etc but after that I'm struggling to find a design I like and one I feel will fit the application. So, I'm reaching out to this group to see if anyone has links to examples, videos, or even ideas on good layout design that could assist me in moving past my writers block for my application. Have a wonderful weekend!
[jQuery] Re: Need help cuz I don't get 'this'
Like MorningZ said, more info would be helpful, but this should work: $('#output').html('SRC: ' + $(this).children('img').attr('src')); --Erik On Sun, Jun 14, 2009 at 7:02 AM, Logictrap dlyck...@gmail.com wrote: I need to get the src attribute of an img element that is a sub- element of 'this' but I can't figure out how to traverse 'this' to get there. The contents of 'this' are: div id=test1img src=images/beach1.jpg width=200 height=200 alt=beach //div this works: $('#output').html(ID: + this.id); This does not: $('#output').html(SRC: + this.img.src); How do I get the contents of the img.src attribute'?
[jQuery] Re: Wait for one function to finish, then start the next....
As you've probably found, there is no sleep/wait/pause in JavaScript. The whole system is single-threaded, so any sort of sleep would hose the whole system. Your original statement doesn't actually make sense. As it is, function2 *doesn't* execute until open_popup returns, so that isn't really your problem. It sounds like you want function2 to execute after something setup within open_popup happens, which you would do with a callback. Good luck. --Erik On Sun, May 24, 2009 at 6:57 PM, macphreak swhit...@gmail.com wrote: No, it doesn't involve Ajax. Although I wish it did. It would be a lot easier for me to define a call back then. :) This is code that I have to work with (or work around I should say) Thanks again for any helpful hints! On May 24, 6:33 pm, Ricardo ricardob...@gmail.com wrote: what's the code for open_popup? does it involve ajax? http://www.ibm.com/developerworks/web/library/wa-ajaxintro2/#N103A2 On May 23, 2:42 pm, macphreak swhit...@gmail.com wrote: I have seen a few of threads on this issue. However, they have mostly deal with the fadeins or fadeouts which is not what I am needing. Here is what I need: On a click event, start function 1. Then after it's finished, start function2. Here is my code: var $j = jQuery.noConflict(); $j(document).ready(function(){ $j(#select_inv).click(function() { open_popup(Inv_Inventory, 600, 400, , true, false, {call_back_function:set_return,form_name:EditView,field_to_name_ar ray: {id:inv_inventory_id_c,name:name_c,make_c:make_c,model_c:mod el_c,year_c:yearmanufactured_c,bodystyle_c:bodystyle_c,vin_c:vi n_c,miles_c:odometer_c,exteriorcolor_c:exteriorcolor_c,interiorco lor_c:interiorcolor_c,trim_c:trim_c,stocktype_c:conditionstocktyp e_c}}, single, true); function2(); }); }); }); Right now, it runs the open_popup function fine. However, it runs function2() immediately. I need it to wait until the open_popup function is finished, and then run the function2() script. Any help would be greatly appreciated! Thanks!
[jQuery] Re: Count how many checkboxes are checked
categoryList.is(':checked') will return false if none are checked, so you could do: heading.css('color', categoryList.is(':checked') ? 'red' : 'black'); --Erik On Wed, Apr 15, 2009 at 8:33 AM, Dragon-Fly999 dragon-fly...@hotmail.comwrote: Hi, I'm new to JQuery and I have a question about checkboxes. I have 5 checkboxes on my page and they are passed into my plug-in. I'd like to find out how many of them are checked in my plug-in. The following code works but I'm sure there is a better way to do it (especially the part of the code that figures out the number of checkboxes checked). Any suggestions would be appreciated. Thank you. = In my aspx page: // $('.category-list') returns a list of 5 checkboxes. $(function() { $('#info-heading').createCategoryGroup($('.category-list')); }); = In my plug-in: // categoryList is a list of checkboxes. (function($) { $.fn.createCategoryGroup = function(categoryList) { var heading = this; // This is an anchor. // Figure out how many checkboxes are checked when the user clicks // on any one of the checkboxes. categoryList.click(function() { // Figure out the number of checkboxes that are checked. var checkedCount = 0; categoryList.each(function() { if (this.checked) { checkedCount++; } }); // End of each. // Set the heading to a different color based on how // many checkboxes are checked. heading.css('color', checkedCount == 0 ? 'black' : 'red'); }); // End of click. return this; } })(jQuery);
[jQuery] Re: Difference between .bind() and .click()
But slower by 1 function call 1 time. I'd call that negligible unless you're developing for a pocket watch. --Erik On Mon, Apr 6, 2009 at 5:08 PM, James james.gp@gmail.com wrote: Not really. hover is theoretically just a very tad bit slower because internally, hover is calling mouseenter and mouseleave: hover: function(fnOver, fnOut) { return this.mouseenter(fnOver).mouseleave(fnOut); } On Apr 6, 1:56 pm, Nikola nik.cod...@gmail.com wrote: Is there any performance difference at all? Say between using .hover vs. binding to mouseenter and mouseleave? On Apr 6, 6:40 pm, James james.gp@gmail.com wrote: Yes, basically two different way to do the same thing. Though with bind(), you can define more than one type of events at once to the same callback. .bind('mouseover mouseout blur', function(){... On Apr 6, 6:53 am, jQueryAddict jqueryadd...@gmail.com wrote: I want to do something based on the click event. I was looking at examples and at the jQuery Docs. Read them but so then a .blind() is adding an event handler where .click() is obviously an event handler but you could I guess use either or to handle for example a click event: .bind('click', function(){... or .click(function(){ right? either will work on whatever element you're working with right? just 2 different ways of doing the same thing in jQuery I assume.- Hide quoted text - - Show quoted text -
[jQuery] Re: jQuery.com homepage News from the jQuery Blog not up to date?!
I'm seeing this too. Quite sure it's not a cache problem on my end as I've never visited jquery.com on this browser before. --Erik On Wed, Mar 11, 2009 at 2:56 PM, MarcusT marcu...@gmail.com wrote: The jQuery.com homepage's currently shows jQuery 1.3.1 Released as the most recent blog post, yet if you look at the blog (or RSS) there have been 6 blog posts since, including the jQuery UI 1.7 and jQuery 1.3.2 releases! Presumably there's some server-side caching going on here and it hasn't updated since some time between the 22nd and 29th January. Please fix this urgently, as many people visiting jQuery.com may fail to realise that much has happened since then!
[jQuery] Re: Using jQuery.noConflict() with Prototype/Scriptaculous
The only thing I might guess is to do jQuery.noConflict() immediately after loading jQuery, before loading any other scripts. --Erik On Tue, Jan 6, 2009 at 8:04 PM, Magnificent imightbewrongbutidontthin...@gmail.com wrote: Hello all, I'm trying to incorporate jquery into pages with prototype. This is what I'm doing in order: 1) Load prototype/scriptaculous 2) Load jquery 3) Execute jQuery.noConflict(); 4) Execute jquery via (function($) { .. })(jQuery); The jquery code isn't being executed (prototype is), does anything look obviously wrong with what I'm doing? I've included a mock of my page source below. html head script src=./js/prototype_min.js type=text/javascript/script script src=./js/scriptaculous/effects_min.js type=text/ javascript/script script type=text/javascript src=http://ajax.googleapis.com/ajax/ libs/jquery/1.2.6/jquery.min.jshttp://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js /script script type=text/javascript src=js/jqModal.js/script script type=text/javascript jQuery.noConflict(); /script /head body page stuff script type=text/javascript //SOME PROTOTYPE STUFF (function() { //all a tags inside if a div class=links tag will open in a new window. Behaviour.register({ 'div.links a' : function(a) { a.onclick = function() { window.open(a.href); return false; } } }); more prototype stuff })(); //START JQUERY (function($) { //START DEMO MODAL var closeModal = function(hash) { var $modalWindow = $(hash.w); $modalWindow.fadeOut('2000', function(){ hash.o.remove(); // removes overlay }); }; more jquery stuff })(jQuery); //END JQUERY /script /body /html
[jQuery] Re: Is this code legitimate?
Using an attribute selector to select by class isn't ideal. Maybe try: $(':input.required') --Erik On Tue, Dec 23, 2008 at 5:52 PM, Rick Faircloth r...@whitestonemedia.comwrote: Is this legit? $(':input[class$=required]') I know it'll work for a div: $('div[class$=required]') but it doesn't seem to work to designate an input with a class that has required on the end of it's name... Rick
[jQuery] Re: if ($(#field).val() == '') or something more elegant?
Maybe try: if($('#text').is(':empty')) --Erik On Sat, Dec 6, 2008 at 2:12 PM, Costaud [EMAIL PROTECTED] wrote: Hello, I'm wondering if this is the correct way of checking whether the textbox is empty or not: if ($(#text).val() == '') Thanks.
[jQuery] Re: if ($(#field).val() == '') or something more elegant?
Whoops, that matches has no children. I think what you did is fine. --Erik On Sat, Dec 6, 2008 at 3:56 PM, Costaud [EMAIL PROTECTED] wrote: That is always saying the field is empty. On Dec 6, 5:24 pm, Erik Beeson [EMAIL PROTECTED] wrote: Maybe try: if($('#text').is(':empty')) --Erik On Sat, Dec 6, 2008 at 2:12 PM, Costaud [EMAIL PROTECTED] wrote: Hello, I'm wondering if this is the correct way of checking whether the textbox is empty or not: if ($(#text).val() == '') Thanks.
[jQuery] Re: passing 'this' into getjson callback
I think anonymous functions are much easier to read and understand. They also make scoping a bit cleaner. You can rewrite with named functions if it makes sense for your application. This is untested, but should be close to what you're asking: jQuery( '#myButton' ).bind( 'click', function() {var theButton = this; jQuery.getJSON( url, null, function( json ) { // handle json stuff here. theButton is the DOM node of the clicked element. // or call handleResult(json, theButton); to pass the element to handleResult } );}); FYI, if this is your real code, this: jQuery.getJSON( url, null, function( json ) { myProject.handleResult( json ) } ); Is the same as this: jQuery.getJSON( url, null, myProject.handleResult ); Creating an anonymous function that just calls a function with the same arguments is redundant. This probably isn't actually what you want in this case though since you then can't pass the button reference. --Erik On Fri, Dec 5, 2008 at 2:16 AM, pramodx [EMAIL PROTECTED] wrote: Hi, On click of a button I am placing a json call in the following manner jQuery( '#myButton' ).bind( 'click', myProject.callJson ); The callJson function calls the json parameters: jQuery.getJSON( url, null, function( json ) { myProject.handleResult ( json ) } ); The handleResult function further takes me to someOtherFunction() as well. The issue is that all the while I need to keep on passing a reference to the clicked button through jQuery(this) so that I can manipulate it in someOtherFunction(). How do I do that? Any pointers would be very helpful. Thanks Pramod
[jQuery] Re: document.getElementById shortcut?
jQuery isn't a replacement for javascript. If you want document.getElementById, use it. If you want a shorter name, shortcut it yourself. If you want to get the DOM node out of a jQuery object, use $(...)[0] --Erik On Sun, Nov 23, 2008 at 9:34 PM, George [EMAIL PROTECTED] wrote: I found myself using document.getElementById often in my coding. Is there a shortcut for it in JQuery? PS: $('#id') is not a shortcut. Since $('#myimage').src will not work. $('#myimage').attr('src') will but I think that document.getElementById is when I do not need extensive JQuery selection ability. Plus it's a) faster b) I can always convert to JQuery collection if I need to do something fancy like var myelement = document.getElementById('myimage'); $(myelement).hide('slow'); PPS: so far i am thinking of creating my own $$('myimage') Thanks George.
[jQuery] Re: How can I return some value in jquery's callback function?
I'm not quite understanding you, but it seems like you need to just pass along callback functions? Maybe you want something like: function checkRegistered(email, doIfRegistered, doIfNotRegistered) { var url='http://localhost/coudou/check/register.php?email=' + email; $.getJSON(url, function(res){ if(res.registed){ doIfRegistered(); }else{ doIfNotRegistered(); } }); } Then you use it like: checkRegistered('[EMAIL PROTECTED]', function() { alert('Alice is registered'); }, function () { alert('Alice is not registered.'); }); You have to use callbacks when you're dealing with asynchronous events. Hope it helps. --Erik On Thu, Nov 13, 2008 at 8:17 PM, Freshow [EMAIL PROTECTED] wrote: Yes, it work but I want define the total as a function be called by different var url, and do different actions judge by true or false returned, any way can realize it ? On 11月14日, 上午1时41分, Michael Geary [EMAIL PROTECTED] wrote: The $.getJSON callback function is not called at the time you make the $.getJSON call. It's called asynchronously, much later, after the data has been downloaded. The return value from the callback is discarded - there's no one to return it to. Did you want to take two different actions depending on the value of res.registed? Then do it right there in the callback. For example: $.getJSON(url, function(res){ if(res.registed){ doOneThing(); }else{ doAnotherThing(); } }); -Mike -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Freshow Sent: Thursday, November 13, 2008 7:58 AM To: jQuery (English) Subject: [jQuery] How can I return some value in jquery's callback function? it didn't work when I 'return true' or 'return false', is there some way to get it? == var url='http://localhost/coudou/check/register.php?email='+http://localhost/coudou/check/register.php?email=%27+str; $.getJSON(url, function(res){ if(res.registed){ return true; // not work }else{ return false; // not work } });
[jQuery] Re: JSLitmus invaluable tool
With Normalize checked, I get infinity for both of them. With it unchecked, I get 12.6M and 10.9M. I'm using google chrome (which the test reports as Safari). --Erik On Tue, Nov 11, 2008 at 9:16 AM, howardk [EMAIL PROTECTED] wrote: I've been experimenting with several different coding styles for plug- ins. Lately I've been curious about the difference in performance between using local variables vs. instance variables for storing state. JSLitmus, while not itself jQuery-based, has just given me the answers I've been looking for. I found them a bit surprising: http://www.fatdog.com/litmus_tests/InstanceVsLocalTest.html (Apologies for the color scheme! :-) Howard
[jQuery] Re: unsubscribe
http://www.google.com/search?q=google+groups+unsubscribe On Mon, Nov 3, 2008 at 9:59 AM, Minal Patki [EMAIL PROTECTED] wrote: I do not wish to recieve any emails from this group. Thanks
[jQuery] Re: Help optimising jquery code - there must be a better way
I don't have time to rewrite your whole example, but I can offer a few tips that might help. Selecting by class alone can be pretty slow. Basically every single tag has to be checked for the class every time you do a selection by class. It would help to at least give the HTML tag that the class is being applied to, like $('li.current_page_item'). You do quite a few next/prev/addClass calls on the same elements, but you're reselecting them every time. I suggest you use the end function. Operations that modify what elements are selected work as a stack, and allow you to undo operations, like so: $(.current_page_item).next().addClass('after').end().prev().addClass('before'); $(.current_page_ancestor).next().addClass('after').end().prev().addClass('before'); Calls to the $ function are often expensive, so it can help to cache them in a local variable if you find you're calling $ with the same parameter multiple times. For that repetitive stuff you're doing at the end, I suggest you look into the each function. Hope it helps. --Erik On Mon, Oct 20, 2008 at 8:08 PM, Kent Humphrey [EMAIL PROTECTED]wrote: I am relatively new to jquery, but have managed to muddle my way through a complicated navigation design that has overlapping selected states, eg with menu items 1,2,3,4 and 5, when item 2 is selected, the images for items 1 and 3 also have to change. The code is long and convoluted, and I am sure there is a cleaner way to do what I am doing. If anyone has any ideas, that would be great. Here's the code: // setup before and after classes $(.current_page_item).next().addClass('after'); $(.current_page_item).prev().addClass('before'); $(.current_page_ancestor).next().addClass('after'); $(.current_page_ancestor).prev().addClass('before'); // do overlapping images $(#primary_nav a).hover( function() { if ((!$(this).parent().hasClass('current_page_ancestor')) (!$(this).parent().hasClass('current_page_item'))) { $(.current_page_item).next().removeClass('after'); $(.current_page_item).prev().removeClass('before'); $(.current_page_item).addClass(current_disabled); $(.current_page_ancestor).next().removeClass('after'); $(.current_page_ancestor).prev().removeClass('before'); $(.current_page_ancestor).addClass(current_disabled); } }, function() { $(.current_disabled).next().addClass('after'); $(.current_disabled).prev().addClass('before'); $(.current_disabled).removeClass(current_disabled); } ); $(#page_item_2 a).hover( function() { $(#page_item_5).addClass('after'); }, function() { if (!$(this).parent().hasClass('current_page_item')) { $(#page_item_5).removeClass('after'); } } ); $(#page_item_5 a).hover( function() { $(#page_item_2).addClass('before'); $(#page_item_7).addClass('after'); }, function () { if ((!$(this).parent().hasClass('current_page_ancestor')) (!$(this).parent().hasClass('current_page_item'))) { $(#page_item_2).removeClass('before'); $(#page_item_7).removeClass('after'); } } ); $(#page_item_7 a).hover( function() { $(#page_item_5).addClass('before'); $(#page_item_9).addClass('after'); }, function () { if (!$(this).parent().hasClass('current_page_item')) { $(#page_item_5).removeClass('before'); $(#page_item_9).removeClass('after'); } } ); $(#page_item_9 a).hover( function() { $(#page_item_7).addClass('before'); $(#page_item_11).addClass('after'); }, function () { if (!$(this).parent().hasClass('current_page_item')) { $(#page_item_7).removeClass('before'); $(#page_item_11).removeClass('after'); } } ); $(#page_item_11 a).hover( function() { $(#page_item_9).addClass('before'); }, function () { if (!$(this).parent().hasClass('current_page_item')) { $(#page_item_9).removeClass('before'); } } ); By way of explanation, this is using the css sprites method where I have a single image that is all the different states of the nav. The 'before' and 'after' classes are used to indicate the nav items either side of the selected item. 'current_page_item' and 'current_page_ancestor' are what WordPress uses to indicate the selected item, or the parent of the selected item. I am using 'current_disabled' to disable the 'current_page_item' style, so when you rollover the other nav items
[jQuery] Re: id same as name confuses JQuery?
I assume your use of braces instead of parenthesis is just a typo? I am unable to reproduce this. This works for me: $('body').append('div id=foobar name=foobar.../div'); $('#foobar').size(); // 1 Could you provide a sample page? --Erik On Mon, Oct 13, 2008 at 1:30 PM, Tim Scott [EMAIL PROTECTED] wrote: Given this element... div id=foo name=foo/div ...why this does not match the element... ${'#foo'} If I change or remove the name attribute, it does match. Is this by design or a bug?
[jQuery] Re: Animate backgroundColor?
A google search for jquery animate color will lead you to the color plugin, which will do what you want. --Erik On Thu, Oct 9, 2008 at 9:43 PM, Jimbo M [EMAIL PROTECTED] wrote: I'm fresh and green to jQuery and enjoying it immensely. One thing I'm used to doing in AJAX is to animate a background-color across a range specified like #fff - #000 When I try doing this using $('#Panel').animate({ backgroundColor: #000}, 1000) I get an error because it doesn't seem to know where to start, even though I'm using CSS to set the background-color to #fff. Is there a way to animate across a color range that I'm missing? This whole jQuery so ROCKS! If I have to learn ANYTHING new this coming month, it's gonna be jQuery! --- Jim ---
[jQuery] Re: OT : javascript editor (with code formatting)
Not free, and probably not what you're looking for, but I can't recommend IntelliJ IDEA enough. Among a lot of other things, it has great JavaScript support with syntax highlighting, refactoring, code completion, and reformatting. --Erik On Tue, Oct 7, 2008 at 8:13 AM, Alexandre Plennevaux [EMAIL PROTECTED]wrote: Friends, aptana studio, albeit a nice editor, is recently crashing all the time and now doesn't even want to restart. I'm looking for a good alternative, that has a code formatting (auto indenting) functionality. Any suggestion ? I'm on Windows XP SP3... Thank you, Alexandre
[jQuery] Re: XML Parsing Question...
To my knowledge, XML parsing via the jQuery constructor isn't supported. See here: http://dev.jquery.com/ticket/3143 --Erik On Sat, Oct 4, 2008 at 12:29 PM, KenLG [EMAIL PROTECTED] wrote: For much of my app, I'm doing an Ajax hit to the server to grab XML. That works great. But, in some cases, I've got too many pieces of data (unrelated) that I need to pull so I'm trying to do a simple passthrough from the server side (I'm using ASP.Net). So, I'll either output from SQL Server or hand-stitch some XML and write it to the page. Whenever I do this passthrough (whether it comes from SQL Server or from my own efforts), the XML doesn't get parsed by Jquery. For example: var sTestXML = '?xml version=1.0?\r \nEventContactsEventContactEventContactDataHello/ EventContactData/EventContact/EventContacts\r\n'; var test = $(sTestXML); alert(test.find(EventContact).length); will result in the alert showing zero. Now, if I lower case some of the tags (and this will vary from XML doc to XML doc but usually it's the root and object-level tags), it'll work. What's going on here?
[jQuery] Re: Possible to set metadata parameter dynamically?
In an older version of the metadata plugin, you used to be able to set something (metaDone to false I think it was) that would force it to reload, but that doesn't work anymore. This is all untested, but here's my read on it: Now, metadata is stored in jQuery's internal caching system, which associates arbitrary data with DOM elements. To remove all metadata for a particular element use: $.removeData(element, 'metadata'); The removeData function is described here: http://docs.jquery.com/Internals/jQuery.removeData#elemname To force one or more elements from a jQuery selection to refresh, try: $(...).each(function() { $.removeData(this, 'metadata'); }); Hope it helps. --Erik P.S.: If you're changing the 'single' option like $(...).metadata({single: 'foo'})..., you need to use the same value for the second parameter to removeData ('foo', in this case). On Sat, Oct 4, 2008 at 1:24 PM, me-and-jQuery [EMAIL PROTECTED]wrote: So is it possible to change the value of metadata parameter? Lets say we have div data={ id: 5 }. Or is the only way to change it with attr(id,6)? I have more parameters for element, so this is not an elegant solution. Thanks.
[jQuery] Re: XHTML Selector Nightmare
Try this: $('.sMarker ~ row', myTable).not($('.eMarker ~ row', myTable)) That will get what you want, but I think it won't include the .sMarker row. To get .sMarker also, maybe try: $('.sMarker,.sMarker ~ row', myTable).not($('.eMarker ~ row', myTable)) You can also do it by index without each() like this: var $rows = $('row', myTable); var $range = $rows.slice($rows.index($rows.filter('.sMarker')), $rows.index($rows.filter('.eMarker'))+1); Hope it helps. --Erik On Wed, Oct 1, 2008 at 11:31 AM, greenteam003 [EMAIL PROTECTED] wrote: I really don't know why I'm having such a hard time with this (maybe its the two monsters and three cups of coffee) but I'm trying to select a range of rows in a 1000 row xhtml table, between starting row with class sMarker and ending row with class eMarker. I'm trying to use the following selector... $('.sMarker ~ row:not(.eMarker ~ row)',myTable) In my mind this should take my .sMarker row, grab all sibling rows after, and then filter out any rows that come after my .eMarker row. Or am I just overthinking this? Currently that selector will select ALL rows after my .sMarker excluding the single row marked with .eMarker. Note: To filter out any responses that are blindingly obvious, the table row tags in my xhtml are really row not tr. I don't know how else to get this between functionality without using indexes and the each iteration is a huge performance loss when dealing with larger tables. Please help because I can not wrap my head around this one this morning. Thanks, greenteam -- View this message in context: http://www.nabble.com/XHTML-Selector-Nightmare-tp19766491s27240p19766491.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: unsubscribe
Perhaps you're looking for: http://groups.google.com/group/jquery-en/subscribe --Erik On Wed, Oct 1, 2008 at 4:18 PM, Steve Schnable [EMAIL PROTECTED] wrote: unsubscribe!
[jQuery] Re: Metadata parameter as selector
The previous responses don't seem to get that you're using the metadata plugin. I would suggest using filter: $('tr').filter(function() { return $(this).metadata().id == 4; })... If you find yourself doing that a lot, you can add a custom selector for metadata. Something like: jQuery.extend(jQuery.expr[':'], { meta: !m[3]||((p=m[3].split('='))(p.length1?$(a).metadata()[p[0]]==p[1]:$(a).metadata()[p[0]])) }); Which you could then use like: $('tr:meta(id=4)')... I put together a little test page: http://erikandcolleen.com/erik/projects/jquery/metaselector/ Seems to work in IE7 and FF3. Untested elsewhere. Hope it helps. --Erik On Mon, Sep 29, 2008 at 10:23 AM, me-and-jQuery [EMAIL PROTECTED]wrote: I am searching the web and documentation and still can't find a working solution. I have a table which rows has also id with metadata, for example tr data={id:4} And now I want to select row with id 4. I was trying many ways but no success for now. For example: $.metadata.setType(attr, data) $(table tr.id:4).metadata().remove(); Anyway, is this possible with metadata at all? Thanks for any help.
[jQuery] Re: Case Insentitive Selectorys
Maybe try using filter and a regexp for the part that you want to be case insensitive. Something like (very untested): $(...).find('item').filter(function() { return this.name.match(new RegExp(search, 'i')); }).each(function() { }); I don't recall the syntax for accessing an XML attribute from javascript, so the this.name part might be wrong. Maybe you need $(this).attr('name') instead. Also, you might want to be doing more than just passing the search into a RegExp, but you get the idea. Also, maybe reconsider what you're trying to do. Maybe just return your xml such that it's already been converted to lower case, then just do what you were doing before except use search.toLowerCase() instead of just search. Hope it helps. --Erik On Mon, Sep 22, 2008 at 12:35 AM, blockedmind [EMAIL PROTECTED] wrote: Nothing? On Sep 20, 5:22 pm, blockedmind [EMAIL PROTECTED] wrote: I am making search in an xml file, but I don't get expected results since jQuery selectors arecase-sensitive. I use something like $(returnedXml).find(item[name*='+search+']).each(function(){ }); How to make it INCASE-SENSITIVE?
[jQuery] Re: Insert variable into a selector
According to the docs, 'this' within a success callback is the options object, so 'this.id' doesn't mean anything useful: http://docs.jquery.com/Ajax/jQuery.ajax#options Also, $(this.id) probably isn't anything useful either. Maybe try this (untested): $('.makeFavorite').click(function() { var id = this.id; $.ajax({ type: POST, url: make_favorite.php, data: id= + id, success: function(msg) { alert('Data saved: ' + msg); $('#' + id + ' img').attr({src : images/+msg+.png}); } }); return false; }); Hope it helps. --Erik On Mon, Sep 22, 2008 at 1:16 AM, suntrop [EMAIL PROTECTED] wrote: This is the JS code: $('.makeFavorite').click(function() { $.ajax({ type: POST, url: make_favorite.php, data: id= + $(this.id), success: function(msg) { alert('Data saved: ' + msg); $('h1 a#' + this.id + ' img').attr({src : images/+msg+.png}); } }); return false; }); The HTML code: h1{$ent.firma} a href={$ent.id} class=makeFavorite id={$ent.id} title=Save favoriteimg src=images/{if $ent.favorit == 1}favorites.png{else}favorites2.png{/if} width=16 height=16 alt= //a/h1 Both variables don't do what what I expect them to do. The first doesn't find the correct target/id and the seccond doesn't insert the image correctly. But if I write down the id and the true path it works fine. What do I have to change? On 22 Sep., 05:42, ricardobeat [EMAIL PROTECTED] wrote: I can't get it either, what are you trying to accomplish? $('h1 a#' + this.id') is not logical, you first need to reference some a element to get it's ID, but in doing that you already wrote the ID... On Sep 21, 11:16 pm, FrenchiINLA [EMAIL PROTECTED] wrote: i think your problem is this.id, you have to show the entire code in order for us to see what does this mean. try just to add a alert for example to see what you get for this.id On Sep 21, 7:38 am, suntrop [EMAIL PROTECTED] wrote: HI there, I want to insert two variables into the selector and an attribute. But it doesn't work. $('h1 a#' + this.id + ' img').attr({src : images/ + msg + .png}); I looked through various tutorials but couldn't find an answer to this. The first variable comes from the object's (a element) id and the seccond is a response from an php script. Can somebody please help me?
[jQuery] Re: Anyone know where to ask jQuery questions?
It's only been 4 hours since your original thread. Seems awfully quick to already be complaining about a lack of response. I looked at your thread and had no idea why XML parsing wouldn't work. I guess I had never come across that before. I didn't respond because I didn't know, and I didn't look at your page because you summed up the problem in your email. It's a high traffic list, so I can't imagine everyone looks at every thread. In the future I suggest you try to use a more meaningful subject, such as Trouble with .each() on XML. Someone who knew about it just skimming might have recognized that and been able to help you (like Jake ultimately did). In terms of other places to get help, the docs are a pretty good, and might have help you in this case as they make no representation that XML parsing from strings works with the jQuery constructor. Also, the IRC channel can be very helpful, as can Google. Good luck. --Erik On Fri, Sep 5, 2008 at 11:53 AM, Jim Buzbee [EMAIL PROTECTED] wrote: I must be in the wrong group. This morning, I posted a question (I must be missing something simple...) on a pared-down jQuery code segment and a URL showing the problem. Out of the 10,000+ members of the mailing list, my Apache log shows a grand total of 1 hit on the example and I got no response on the mailing list. I must be in the wrong list. Is there somewhere to ask jQuery questions? Once again, the code in question can be found at: http://batbox.org/bh.html It works under firefox/safari, and doesn't under IE7 Thanks, Jim Buzbee
[jQuery] Re: New Google Browser announced
However, as Google mentions themselves, if your website is compatible with Safari 3 it should autmatically also be compatible with the current Chrome version. Sort of. It's not an issues of a new renderer to support (WebKit, same as Safari/Android), it's an issue of a new JavaScript engine to support (V8), which is a real concern as the jQuery test suite apparently fails a couple of tests on Chrome. --Erik
[jQuery] Coverflow
No association with jQuery, but here's a nice JavaScript coverflow effect that I thought people might like: http://radnan.public.iastate.edu/coverflow/ It mucks around with extending builtin objects, which is bad form to us jQuerians, but it's a nice effect. --Erik
[jQuery] Re: Cross domain problems
The problem arises when you're on http://username.example.com/ and you want to make an ajax request to http://example.com/ or you're on http://example.com and you want to make a ajax request to http://ajax.example.com/ You'll have cross-domain issues since the domains aren't the same. But since your SLD is the same, you can set document.domain to 'example.com' and everything will play nice. If you make your ajax requests to the same server that served up the page that you're on, then this isn't an issue as you can just us an absolute URI, as you suggested. But such isn't always the case, especially on larger sites. --Erik On 7/10/08, Vincent Robert [EMAIL PROTECTED] wrote: I may be misunderstading something here but this does not look like a cross-domain issue to me. If you are making AJAX request on the same server that served the page, then you should use absolute URI path without any protocol nor domain name : $.get(/some/web/service). This will work whatever domain your user typed in his browser (www.example.com or example.com). If you are really making a cross-domain AJAX call, meaning that you are calling another server (like yahoo.com or google.com) then browsers will prevent you from doing that and you should rely on a proxy webservice that you must create on your server. Have I missed something obvious? On Jul 10, 4:07 am, flycast [EMAIL PROTECTED] wrote: I have determined that the error was from a different script. Sorry about the confusion. After working on the document.domain I could not get it to work/help. The load statement would just not return any result. The solution that Jeffery offered above worked like a champ. Thanks for all your help. On Jul 9, 11:56 am, Jeffrey Kretz [EMAIL PROTECTED] wrote: I had this same problem, which I solved by parsing the window.location.href prior to making the ajax call, based on the current host used to access the site. var url = /(https?:\/\/[^\/]+)/.exec(window.location.href)[1] + '/pathtomyresource'; JK -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Erik Beeson Sent: Wednesday, July 09, 2008 9:33 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Cross domain problems The protocol *must* be the same (if the page ishttps://.../thenthe ajax request must also be tohttps://.../). The port *must* be the same. The host name *must* have the same SLD [1], and if the subdomains are different, document.domain *must* be set to the SLD. I'm certain that this can work as I do it all the time. If you're still having trouble, could you create a page that demonstrates the problem? --Erik [1]http://en.wikipedia.org/wiki/Second-level_domain On 7/9/08,flycast[EMAIL PROTECTED] wrote: I tried setting document.domain = 'site.com'; It works with a domain of site.com but notwww.site.com. I now get the following message: [Exception... 'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent] nsresult: 0x8057001e (NS_ERROR_XPC_JS_THREW_STRING) location: unknown data: no] This seems to be a different problem. BTW...here is a Mozilla link to the issue of cross domain and the use of document.domain:http://www.mozilla.org/projects/security/components/same-origin.html On Jul 9, 1:30 am, Alexsandro_xpt [EMAIL PROTECTED] wrote: Well, I thought this is security browser issue. I always solve this problem this way: Eg.: To ajax this:http://feedproxy.feedburner.com/undergoogle I create this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c.. . -- Alexsandrowww.alexsandro.com.br On 9 jul, 00:18, Erik Beeson [EMAIL PROTECTED] wrote: Add this somewhere in your javascript: document.domain = 'site.com'; Google document domain --Erik On 7/8/08,flycast[EMAIL PROTECTED] wrote: Simple problem (I think)... I am new to JS and ajax. I am building an ajax capability on a clients site. I am running into cross domain problems. If I get the page using the url formhttp://www.site.com but I do a load using the url form http://site.com; (www vs. no www in the url) I get nothing but a js error. What is the best way to handle making sure that if the person is at the site with OR without the www in the url that the .load will still work?
[jQuery] Re: array method on a jQuery object: deleting, adding elements
Check out the functions here, particularly under Filtering: http://docs.jquery.com/Traversing --Erik On 7/12/08, wolf [EMAIL PROTECTED] wrote: hi all, since a jQuery collection (say, `var j = $( 'div' )`) looks and behaves a bit like a standard javascript array (you can iterate over it, fetch single elements using `j[n]`, delete everything doing `j.length = 0`), what is the preferred way to do other array-like manipulations on it? let's say i have `j` as defined above, and want to throw out (from the collection, not from the document) any element that the user clicks on, how could i do that? i browsed parts of the source but did not grok where a jQuery object keeps its collection of elements (my own javascript code looks like cave painting in comparison). am i missing something terribly obvious here? _wolf heckc out the stuff under filtering:
[jQuery] Re: Cross domain problems
The protocol *must* be the same (if the page is https://.../ then the ajax request must also be to https://.../). The port *must* be the same. The host name *must* have the same SLD [1], and if the subdomains are different, document.domain *must* be set to the SLD. I'm certain that this can work as I do it all the time. If you're still having trouble, could you create a page that demonstrates the problem? --Erik [1] http://en.wikipedia.org/wiki/Second-level_domain On 7/9/08, flycast [EMAIL PROTECTED] wrote: I tried setting document.domain = 'site.com'; It works with a domain of site.com but not www.site.com. I now get the following message: [Exception... 'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent] nsresult: 0x8057001e (NS_ERROR_XPC_JS_THREW_STRING) location: unknown data: no] This seems to be a different problem. BTW...here is a Mozilla link to the issue of cross domain and the use of document.domain: http://www.mozilla.org/projects/security/components/same-origin.html On Jul 9, 1:30 am, Alexsandro_xpt [EMAIL PROTECTED] wrote: Well, I thought this is security browser issue. I always solve this problem this way: Eg.: To ajax this:http://feedproxy.feedburner.com/undergoogle I create this:http://blog.alexsandro.com.br/application/load/feedproxy.feedburner.c... -- Alexsandrowww.alexsandro.com.br On 9 jul, 00:18, Erik Beeson [EMAIL PROTECTED] wrote: Add this somewhere in your javascript: document.domain = 'site.com'; Google document domain --Erik On 7/8/08, flycast [EMAIL PROTECTED] wrote: Simple problem (I think)... I am new to JS and ajax. I am building an ajax capability on a clients site. I am running into cross domain problems. If I get the page using the url formhttp://www.site.com but I do a load using the url form http://site.com; (www vs. no www in the url) I get nothing but a js error. What is the best way to handle making sure that if the person is at the site with OR without the www in the url that the .load will still work?
[jQuery] Re: Cross domain problems
Add this somewhere in your javascript: document.domain = 'site.com'; Google document domain --Erik On 7/8/08, flycast [EMAIL PROTECTED] wrote: Simple problem (I think)... I am new to JS and ajax. I am building an ajax capability on a clients site. I am running into cross domain problems. If I get the page using the url form http://www.site.com but I do a load using the url form http://site.com; (www vs. no www in the url) I get nothing but a js error. What is the best way to handle making sure that if the person is at the site with OR without the www in the url that the .load will still work?
[jQuery] Re: Need truncator/Expander help (trimming on # of objects rather than character count)
Seems to have some HTML escaping issues on your options page: http://plugins.learningjquery.com/summarize/index.html#options At least in Safari. --Erik On 7/6/08, Karl Swedberg [EMAIL PROTECTED] wrote: sorry, but I'm changing the name from summarizer (with an r) to summarize. Seems to make more sense as a verb. so now you can find it at: http://plugins.learningjquery.com/summarize/ --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Jul 6, 2008, at 3:22 PM, Karl Swedberg wrote: sounds like a reasonable thing to want, so I just whipped up a new plugin for you: http://plugins.learningjquery.com/summarizer/ Please keep in mind that it hasn't been tested extensively, and the documentation is kind of spotty, but it shouldn't be too hard to figure out how it works. One important thing to note is that your selector should be the parent element of the elements you want to expand/collapse. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Jul 6, 2008, at 11:55 AM, clorentzen wrote: I am looking to add an expander/truncator feature to a site I'm building. However, the plugins and other code snippets I've found cut off text based on character count. What I'm looking for is something that cuts off based on a specific number of paragraphs. So, for example, inside a targeted div, after the second p it would hide all remaining ps, and insert a read more link. Clicking would expose the hidden elements and add a read less link. I haven't been able to figure out a way to do this... Can anyone point me in the right direction? I've posted an example page here: http://www.cement-site.com/truncator/example.shtml It's making use of the truncator plugin found here: http://henrik.nyh.se/2008/02/jquery-html-truncate (I've also tried Karl Swedberg's Expander plugin, but it doesn't seem appropriate in this case since it's not intended to truncate/expand across multiple block-level elements.) Can this truncator plugin code be modified to count ps rather than characters? Or is there a simpler/better way to accomplish this? Thanks!
[jQuery] Re: Why (function($){ ...})(jQuery) instead of (function(){var $ = jQuery; ...})()?
On Fri, Jul 4, 2008 at 7:29 AM, Ariel Flesler [EMAIL PROTECTED] wrote: Note that the (function($){ ... })(jQuery); approach is 6 bytes shorter than (function(){ var $ = jQuery; })(); It also looks cooler ;) These were exactly the points I was going to make. Since $ is really a utility function, having a variable declaration for it all the time seems ugly. The closure trick feels much cleaner, and nicely separates my local variables from the $ function. Plus it's shorter. --Erik
[jQuery] Re: Passing a variable into the $('selector') function
If msg is '#myDiv' and you have element with id=myDiv, then $(msg) will select it. If you think that's what you're doing and it isn't working for you, either your id is wrong or msg doesn't hold what you think (maybe it has a trailing \n?). --Erik On 7/2/08, Stompfrog [EMAIL PROTECTED] wrote: Hi all, I have a problem that I can't crack. I have a function similar to this.. $.ajax({ type: POST, url: some.php, data: name=Johnlocation=Boston, success: function(msg){ alert( Data Saved: + msg ); } }); The data that gets passed back to the function from some.php is a string which is the id of the div that I want to manipulate in the callback function e.g. #myDiv. My question is how can I get that div from the callback function using the msg variable because $(msg); doesn't work and neither does $ ('+msg+'); Thanks in advance, Stompfrog
[jQuery] Re: Position cursor at end of textbox?
Ick! Global variables and eval'd code! How about (untested, logic should be unchanged): $(function() { $(':text').bind('focus', function() { var o = this; if(o.setSelectionRange) { /* DOM */ setTimeout(function() {o.setSelectionRange(o.value.length,o.value.length);}, 2); } else if(o.createTextRange) {/* IE */ var r = o.createTextRange(); r.moveStart('character', o.value.length); r.select(); } }); }); Adds an anonymous function, which adds a function call, but saves an eval and doesn't require a global variable, which is potentially problematic. --Erik On 7/2/08, Brian J. Fink [EMAIL PROTECTED] wrote: And I checked my code again. It DOES work on FF3, FF2, and IE7. On Jul 2, 5:37 pm, Paul Malan [EMAIL PROTECTED] wrote: Thanks for the code. It doesn't work for me--still when I tab into a textbox in either IE7 or FF3 the content is selected and the cursor isn't positioned at the end of the text, even when I pull out everything but this function and two textboxes to test. I think I may just give up--it was a minor detail and not requested by the users. Bugs me, though. Seems like it shouldn't be so tricksy... On Jul 2, 3:12 pm, Brian J. Fink [EMAIL PROTECTED] wrote: There may be a jQuery way to do this, but I don't know what it is. However, I do know 2 ways to accomplish this: one DOM way, one IE way. Both methods must be employed. $(function() { $('input[type=text]').bind('focus',function() { window.o=this; if (o.setSelectionRange) /* DOM */ setTimeout('o.setSelectionRange(o.value.length,o.value.length)',2); else if (o.createTextRange) /* IE */ { var r=o.createTextRange(); r.moveStart('character',o.value.length); r.select(); } }); }); On Jul 2, 2:55 pm, Paul Malan [EMAIL PROTECTED] wrote: By default it seems browsers select all the text in a textbox when it gains focus by way of a tab-press. I would like the cursor to be positioned at the end of any existing text in the input, instead. The examples I'm turning up on Google don't work and seem needlessly complex, and since jQuery simplifies everything else I used to hate about Javascript, I thought I'd see if there's a simple way to position the cursor in a text input box on focus. Is it doable? Thanks...
[jQuery] Re: Position cursor at end of textbox?
No worries. Thanks for taking the time to test it :) Scoping is probably one of the most unobvious aspects of JavaScript. --Erik On 7/2/08, Brian J. Fink [EMAIL PROTECTED] wrote: My apologies, Erik. Yours is the superior method. I must have been remembering the behavior of IE5. On Jul 2, 8:12 pm, Erik Beeson [EMAIL PROTECTED] wrote: Ick! Global variables and eval'd code! How about (untested, logic should be unchanged): $(function() { $(':text').bind('focus', function() { var o = this; if(o.setSelectionRange) { /* DOM */ setTimeout(function() {o.setSelectionRange(o.value.length,o.value.length);}, 2); } else if(o.createTextRange) {/* IE */ var r = o.createTextRange(); r.moveStart('character', o.value.length); r.select(); } }); }); Adds an anonymous function, which adds a function call, but saves an eval and doesn't require a global variable, which is potentially problematic. --Erik On 7/2/08, Brian J. Fink [EMAIL PROTECTED] wrote: And I checked my code again. It DOES work on FF3, FF2, and IE7. On Jul 2, 5:37 pm, Paul Malan [EMAIL PROTECTED] wrote: Thanks for the code. It doesn't work for me--still when I tab into a textbox in either IE7 or FF3 the content is selected and the cursor isn't positioned at the end of the text, even when I pull out everything but this function and two textboxes to test. I think I may just give up--it was a minor detail and not requested by the users. Bugs me, though. Seems like it shouldn't be so tricksy... On Jul 2, 3:12 pm, Brian J. Fink [EMAIL PROTECTED] wrote: There may be a jQuery way to do this, but I don't know what it is. However, I do know 2 ways to accomplish this: one DOM way, one IE way. Both methods must be employed. $(function() { $('input[type=text]').bind('focus',function() { window.o=this; if (o.setSelectionRange) /* DOM */ setTimeout('o.setSelectionRange(o.value.length,o.value.length)',2); else if (o.createTextRange) /* IE */ { var r=o.createTextRange(); r.moveStart('character',o.value.length); r.select(); } }); }); On Jul 2, 2:55 pm, Paul Malan [EMAIL PROTECTED] wrote: By default it seems browsers select all the text in a textbox when it gains focus by way of a tab-press. I would like the cursor to be positioned at the end of any existing text in the input, instead. The examples I'm turning up on Google don't work and seem needlessly complex, and since jQuery simplifies everything else I used to hate about Javascript, I thought I'd see if there's a simple way to position the cursor in a text input box on focus. Is it doable? Thanks...
[jQuery] Re: SproutCore vs jQuery? Are there any comparisons out there?
I guess maybe it'll be cool eventually since Apple is apparently backing it? But from the demos so far, it looks extremely half-baked... --Erik On 6/17/08, Andy Matthews [EMAIL PROTECTED] wrote: Yeah...that's what I thought. I've never even heard of it before WWDC. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Rey Bango Sent: Tuesday, June 17, 2008 10:29 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: SproutCore vs jQuery? Are there any comparisons out there? There are no comparisons out at the moment. While SproutCore has recently received a lot of press, it's been completely out of the limelight otherwise. Rey... Andy Matthews wrote: I'm looking for comparisons between the newly popular JS library SproutCore and our own favorite, jQuery. Mostly I'm looking for feature comparisons in the area of data binding and UI. SproutCore's got to be good if Apple decided to use it for their recerntly announced MobileMe online app. But why? Why not jQuery, or Dojo, etc? * Andy Matthews *Senior ColdFusion Developer Office: 615.627.9747 Fax: 615.467.6249 www.dealerskins.com http://www.dealerskins.com/ Total customer satisfaction is my number 1 priority! If you are not completely satisfied with the service I have provided, please let me know right away so I can correct the problem, or notify my manager Aaron West at [EMAIL PROTECTED]
[jQuery] Re: Is there a way to use the css function with $(document) directly?
This worked for me on FF2/Mac: $('style/style').attr('type', 'text/css').text('div { background: red; }').appendTo('head'); --Erik On 6/16/08, Brian J. Fink [EMAIL PROTECTED] wrote: I didn't mean $(element).css(object), I meant $ (document).css(selector,rule). The difference is this: css() as it stands makes a one-time change to the members of the jQuery object by adjusting the style attribute of each. When a new element matching the query string is created, it does not have the desired css values. Trust me: I've already tested it. What I'm talking about is a way to directly manipulate the document's style sheets using jQuery. On Jun 16, 4:32 am, Olaf Bosch [EMAIL PROTECTED] wrote: Brian J. Fink schrieb: $(document).css(selector1,rule1).css(selector2,rule2)...css(selectorN,ruleN); If this is already part of the jQuery functionality, tell me the syntax to use. Yes, it's ON: $(p).css({ color: red, background: blue }); -- Viele Grüße, Olaf --- [EMAIL PROTECTED]://olaf-bosch.de/http://ohorn.info/http://www.akitafreund.de/ ---
[jQuery] Re: $(#content).load('http://www.google.com.br') is a possible ?
Use an iframe or read up on cross domain ajax. --Erik On Thu, Apr 24, 2008 at 1:27 PM, Luciano Mazzetto [EMAIL PROTECTED] wrote: Hi, I need loading http request inside my div content. I do this it $(#content).load(http://www.google.com.br;); but i hadn't sucess How i can load this page in my div ? tks..
[jQuery] Re: Which jQuery method to use in this scenario
The formSerialize function from the form plugin does exactly what you're asking for: http://www.malsup.com/jquery/form/#api The form plugin also has a variety of functions for submitting forms via ajax. Hope it helps. --Erik On 4/23/08, neualex [EMAIL PROTECTED] wrote: Guys, I am new with jQuery, and I was trying to do something very simple for you at least. I am using jQuery against classic ASP pages and I need to send a form to a ASP page and come back with XML results. So, question: Is there an easy way to just identify the FORM and send all the element values by default without actually building up the value string in the $.post method. $.post(process.asp, { name: neualex, pass: password }, function(data){ alert(data); }); I review the documentation, but to be honest I find it difficult. If you have samples on the scenario above in PHP or better yet ASP, please send them to me. I'd appreciate your support. Thanks, neualex
[jQuery] Re: Focus First 'visible' field
Your inner $(this).filter(...) doesn't make sense to me. This works for me on FF2/Mac: $(':input:visible').filter(function() { return $(this).parents(':hidden').length == 0; }).slice(0,1).focus(); That is: Select all visible inputs elements, filter out any who have parents which are hidden, select the first one of those that remain, focus it. --Erik 2008/4/21 Jacky See [EMAIL PROTECTED]: Someone found that this method does not handle visibility correctly. When a visibility:hidden parent with a visibility:show child, the child would override its parent's property (of course!). So the script only need to check display:none parent, which would introduce another filter: $(:text:visible:enabled).filter(function(){ return $(this).filter(function(){ this.style.display == none; }).size()==0; }).eq(0).focus(); On 4月17日, 下午9時40分, Jacky [EMAIL PROTECTED] wrote: To work on any type of input should be easy, just replace ':text' with input. I know that IE would give error when you're focusing a 'disappearing' input. (parent is hidden, for example). But I do not encounter any error like you described. Any sample code for your HTML? On Tue, Apr 15, 2008 at 9:00 AM, MichaelEvangelista [EMAIL PROTECTED] wrote: I've been looking for a solution like this, but that will work with any type of form input. The code I've been using is below (where form-id is the ID of the containing form) It works great in Firefox but IE throws the error 'this.parentNode.borderCss.on' is null or not an object I tried your example code above, and got the same error here is what I was using : // --- Put the cursor in the first field on page load var $firstfield = function(){ $('#form-id input:eq(0)').focus(); } $firstfield(); Could this have anything to do with my markup? I didnt get that error on your demo, but i did when I applied your code to my form. On Apr 13, 7:54 am, Jacky See [EMAIL PROTECTED] wrote: Hi all, For focusing first input text field, the usual solution is $ (':text:visible:enabled:eq(0)').focus(). However, when these fields are in an ':hidden' parent (not 'visible' by our eyes), it won't work. Currently I tried to solve this by: $(:text:visible:enabled).filter(function(){ return $(this).parents(:hidden).size()==0; }).slice(0,1).focus(); I have setup a test page for this: http://www.seezone.net/dev/focusField.html Try to toggle different parent to and click 'focus'. It should work correctly. I would like to know if there is any other 'selector-based' way to do so? -- Best Regards, Jacky 網絡暴民http://jacky.seezone.net
[jQuery] Re: What do you use?
Java. See also, this thread: http://groups.google.com/group/jquery-en/browse_thread/thread/ce0ddf8919cb9334/2613d125f737387d --Erik On Wed, Apr 16, 2008 at 4:31 AM, Chalkers [EMAIL PROTECTED] wrote: Hi jQueryers, I am curious what people use as on the server side with jQuery? PHP, ASP, Groovy/Java/Spring, RoR, something else or nothing, just plain old (x)HTML? I generally use PHP but have used it with Java and Grails. Regards, Andrew
[jQuery] Re: Find a exact location in the dom, then move down from that location to another element
I'm not quite sure what you're asking for, but it sounds like you might want to check out the docs on selecting and traversing: http://docs.jquery.com/Selectors http://docs.jquery.com/Traversing Hope it helps. --Erik On 4/10/08, sleepwalker [EMAIL PROTECTED] wrote: Is there a way in jquery to find your exact location in the dom and then move down from that location to another element? For example can I get the value of a input[text].someClass after changing it and write that change only to the next td.someOtherClass in the dom without using an id?
[jQuery] Re: Is there an Event.stop for hrefs?
Returning false is fine, but there's also event.preventDefault(): http://docs.jquery.com/Events_%28Guide%29#event.preventDefault.28__.29 $('a').click(function(e) { e.preventDefault(); }); --Erik On 4/6/08, Michael Sharman [EMAIL PROTECTED] wrote: Hi guys, I am listening for an href click in my document.ready function and I want to make sure the href isn't followed by the browser for users who have javascript turned on, and is followed by users who have javascript turned off. This is my href: a href=http://mysite.com/gohere.html; id=hrefCreateClick me/a The way I'm doing the javascript is (note the return false): $(document).ready(function(){ $('a#hrefCreate').click(function(){ //do something here return false; }); }); This is working fine (i.e. the return false) but I just want to check if this is the best practice way to do this and if it's cross browser etc. The reason I ask is that in Prototype.js there is an Event.stop which halts all processing and allows you to do what you want in your function. Is there similar in jQuery or will return false suffice? Thanks guys.
[jQuery] Re: jEditable issue in Firefox 2.0.0.13
(and is jEditable the best edit-in-place plugin for jQuery anyway?) Yes.
[jQuery] Re: check/uncheck via toggle
Also, '[EMAIL PROTECTED]' can be replaced with ':checkbox'. --Erik On 4/2/08, Karl Rudd [EMAIL PROTECTED] wrote: The toggle() function is used to hide and show items, nothing to do with clicking or changing of state. http://docs.jquery.com/Effects/toggle What you want is something like: $('[EMAIL PROTECTED]').click( function() { if ( this.checked ) $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000); else $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000); } ); Karl Rudd On Thu, Apr 3, 2008 at 12:41 PM, Bruce MacKay [EMAIL PROTECTED] wrote: Hello folks, I have a table of data, with each row containing a checkbox. What I want users to be able to do is tick the box of each row of data they want to delete (and after ticking, they will submit the form etc etc. As a visual aid, I want to alter the background colour of the row - and if they untick a selection, to reverse that background colour change. My code as follows achieves the background colour toggle, but the checkboxes are neither checked or unchecked. I'd appreciate someone pointing out my error? $('[EMAIL PROTECTED]').toggle( function() { $(this).attr('checked',true); $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000); }, function() { $(this).attr('checked',false); $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000); } ); Thanks Bruce
[jQuery] Re: missing ( before formal parameters
missing ( before formal parameters $(#postcode).change(function{$(#town).val(zipToCityHash.$(#postcode).val()... Also, I see what you're trying to do there, but you can't access object properties like that. You probably want something like: $(#postcode).change(function() { $(#town).val(zipToCityHash[$(#postcode).val()]); }); Plus, you don't need to select #postcode again. You can access it with 'this' in the event handler: $(#postcode).change(function() { $(#town).val(zipToCityHash[this.value]); }); And, if the user enters a zip that isn't in your hash, val() will get passed undefined, which does the same thing as calling val() with no arguments: it returns the current value without changing it. So if you want to change or clear town if the user enters a zip that isn't in your hash, you could do something like: $(#postcode).change(function() { if(zipToCityHash[this.value]) { $(#town).val(zipToCityHash[this.value]); } else { $(#town).val(); // clear town, or whatever you want to do in this case } }); Hope it helps. --Erik
[jQuery] Re: Attribute Selector
You have some oddly mismatched quotes, but otherwise, yes, that works. Here's a test done in firebug on jquery.com: $('[EMAIL PROTECTED]:][href*=book]').each(function() { console.log(this.href );}); http://www.packtpub.com/jQuery/book/mid/1004077zztq0 http://www.packtpub.com/jQuery/book/mid/1004077zztq0 Hope it helps. --Erik On 2/25/08, Smith, Allex [EMAIL PROTECTED] wrote: Correct me if I am wrong... This selector should: [EMAIL PROTECTED] [EMAIL PROTECTED]:[EMAIL PROTECTED] somedomain.com] only select links that start with mailto:; and contain somedomain.com Correct? Allex
[jQuery] Re: what editor do you use?
IntelliJ IDEA and gvim. I use gvim literally all the time. I have an icon on my dock for Open with gvim that I can just drop files on. Very handy. The nice thing about gvim (or vi in general I guess), is that while there are a lot of commands, way more than anyone would be expected to learn all in one sitting, the basic commands to get you started are pretty easy. i, ESC, x, :wq are enough to get you started. And eventually you get tired of deleting one character at a time, so you go lookup other delete commands, and find dw to delete a word, and dd to delete a line. Then you figure out that the d* commands cut, and p pastes. Then, when you get tired of doing ddP to copy via cut-n-paste, you find yy copies (yanks) without cutting. You get tired of cutting one line at a time, so you find that prefixing any command with a number makes it operate that many times. Anyways, I could go on forever, but the point is it's not actually that hard. Oh, and IDEA is awesome also. Well worth the $$$. I just wish it had better Scala support. --Erik On 2/13/08, Feijó [EMAIL PROTECTED] wrote: I changed my own a few weeks ago, now I'm using Editpad++ ( http://sourceforge.net/projects/notepad-plus/) its freeware, nice resources, like macros, quick-text, highlighted source, ... and yours? -- Feijó
[jQuery] Re: Counting DIVs with class x within a larger DIV
Untested, but should work: $('#data .x').length --Erik On 2/12/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Sure this is simple, still trying to get a handle on the basics of JQuery. Given a DIV with id = data, how would I count the number of DIVs with class = x, within the larger DIV data? Thanks, - Dave
[jQuery] Re: How to logically AND selectors?
Generally, just run them together with no space. A div tag with ID foo and class bar: div#foo.bar Any tag with classes class1 and class2: .class1.class2 etc Hope it helps. --Erik On 1/30/08, Kynn Jones [EMAIL PROTECTED] wrote: Hi. The docs describe selectors of the form selector1, selector2, selector3 as matching the combined results of all the specified selectors, by which they mean the set union of all the individual selections. In other words, the ',' here behaves like a logical OR. Is there a succinct way to perform the correspond logical AND? I.e. what's the best way to obtain the set intersection of multiple selections? TIA! kynn
[jQuery] Re: How to logically AND selectors?
You're looking for:.selector1.selector2.selector3 But, that's only if selector1, selector2, and selector3 are all classes, yes? --Erik
[jQuery] Re: how to get php to detect if it's an ajax call or a normal full page call
The request header X-Requested-With is set to XMLHttpRequest for all AJAX calls from jQuery. Hope it helps. --Erik On 1/29/08, Alexandre Plennevaux [EMAIL PROTECTED] wrote: Hello, so that my php script can serve both ajax calls and full page call if javascript is not available on the client platform, i usually append a js=1 to all links. So it's a child play to test for $_GET['js']==1 on the server and serve the relevant html. Now, i've switched my application to use pretty url, thus cannot use that trick anymore. I would like to know if there is another possibility, possibly in the http-header sent by jquery ? Thanks a lot for your help, Alexandre
[jQuery] Re: Feb 12 IE6 Forced Update
I don't usually run both at the same time, but I have, and it works. I'm on a 2GHz Core 2 Duo iMac with 3GB of RAM (the most it will take). I use both Parallels and Fusion because I started with Parallels, and it has more features, but it's more resource intensive, so for things like video conferencing from within Windows, Fusion works much better. Seriously, I can not stress enough that getting a Mac has significantly increased my web development productivity (can test FF Mac/Windows, Safari Mac/Windows, IE6/7 (in true separate OS instances), Linuxes, etc). As has dual screens (though I'd really like 3: one for code, one for the web browser, and one for server logs/terminal). I've been a diehard, build my own PC user forever, but now I tell everyone to get a Mac. Sorry to wonder OT. --Erik On 1/24/08, Mika Tuupola [EMAIL PROTECTED] wrote: On Jan 24, 2008, at 7:16 PM, Karl Swedberg wrote: Of course you could also install two virtual machines, one with IE6 and one with IE7. I do this with my Mac and Parallels (Fusion also works well), and I'm sure there are Windows VM apps out there. I could imagine running two Windowses at the same time is quite a memory hog. How much do you have? 10G ? :) -- Mika Tuupola http://www.appelsiini.net/
[jQuery] Re: animation queue ?
Check out here: http://erikandcolleen.com/erik/jquery/fxQueue/ Demo: http://erikandcolleen.com/erik/jquery/fxQueue/random.html Or here: http://brandonaaron.net/jquery/plugins/fxqueue/ Demo: http://brandonaaron.net/jquery/plugins/fxqueue/test/test.html --Erik On 1/17/08, Alexandre Plennevaux [EMAIL PROTECTED] wrote: hi friends, i'm storing the steps of a series of animations in an array, that have to occur one after the others, according to their index order in the array. Example: animArray['section', 'item','object1','object2' ]; i would like to run a function that loops through the array, and for each element in the array, perform the animation, then when the animation is finished, move on to the next element, do its related animation, etc... until the array is finished. Now, how do i make the animation queue one after the others? Thanks for any feedback/hint, Alexandre
[jQuery] Re: a way to convert jquery object to text for dom injection
Maybe try (untested): $('div').append('text blab bla').append($('#d')).append('ok nana'); --Erik On 1/13/08, Equand [EMAIL PROTECTED] wrote: i need to insert a clone of one dom object i do var hex = $(#d).clone(); $(div).append(text blab bla+hex+ok nana); and it's not working... how do i do this?
[jQuery] Re: Sorting with each()
I seem to be the only person to care about sort in jQuery. This ticket has a sort function that worked with 1.1, though I'm not sure if it still does. Make sure to scroll down to the bottom for the most recent version: http://dev.jquery.com/ticket/255 For example, to sort the children of an element with id foo: $('#foo').children().sort(function(a, b) { ... }).prependTo('#foo'); You have to reinsert them into the DOM after sorting them, and 'a' and 'b' are DOM nodes, not jQuery objects. Hope it helps. --Erik On 1/14/08, monster79 [EMAIL PROTECTED] wrote: Hi all, I'm looking for an elegant method to sort elements returned from find() or an each() callback. Currently I'm dumping the elements' text into a Javascript array with push(), then sorting the array with .sort() and printing the results with a for() loop. This works well, but it doesn't seem like the jQuery way to do it. Any suggestions? Jonas
[jQuery] Re: jQuery 1.1.2 Released: Happy 2nd Birthday!
I thought I was having a flashback as I swear I remembered 1.1.2 being released a while ago: http://jquery.com/blog/2007/02/27/jquery-112/ Ahh, a typo I see. At least it's right in the blog. Congrats! Keep up the awesome work. --Erik On 1/14/08, John Resig [EMAIL PROTECTED] wrote: On the 2nd birthday of jQuery we're happy to bring you a new release of jQuery! Here's the announcement: http://jquery.com/blog/2008/01/15/jquery-122-2nd-birthday-present/ and here's the release notes: http://docs.jquery.com/Release:jQuery_1.2.2 Enjoy - and here's looking forward to another year of excellent jQuery code! --John
[jQuery] Re: [ANNOUNCE] Cornerz - Bullet Proof Curved Corners using Canvas/VML
Your choice of colors aside, this plugin looks fantastic! Very smooth. If this had gradients and drop shadows, I could replace my photoshop guy with it :) --Erik On 1/7/08, weepy [EMAIL PROTECTED] wrote: Hi I'd like to announce my latest jQuery plugin. I hope you'll find it useful. FEATURES: # Antialiased # Very Fast # Support for any size radius and border width with minimal performance increase # No excanvas # Current layout is maintained # Works with all tested positions/display/floats # Supports fluid layouts # Original div still shows through, so can easily do hover/background effects # Script is only 4.0k uncompressed Issues # IE6 has some slight problems with the VML in some cases # Mac/Safari doesn't work (Windows Safari is fine) You can see it in action here : http://www.parkerfox.co.uk/cornerz Look forward to your comments Jonah
[jQuery] Re: Select elements in order
See my responses regarding this issue in this thread: http://groups.google.com/group/jquery-en/browse_thread/thread/c21d5c20bfd25f6c/f42894299920f05d?lnk=gst --Erik On 12/24/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I want to select some items on my page in the order they appear, but it seems that jQuery selects them in the order that my selectors are written instead. So: $('h1,h2,h3') gets me all the h1s, then all the h2s, then all the h3s. Is there a way to get them in the order they appear in my document instead? Barring that, it's almost like I need a way to say select all the h2's after this h1 UNTIL you find another h1 or an h3 ... Any help would be appreciated!! Rebecca http://blog.rebeccamurphey.com
[jQuery] Re: (this).next problem
Siblings are tags who have the same parent. For example: foobar.../barfar.../far/foowax.../wax bar and far are siblings, foo and wax are siblings, far and wax aren't siblings. Maybe try this: $('.collapse_device').click(function() { $(this).parents('.device_header').next().hide(); }); That will walk up the hierarchy to an element with class device_header, then find the next sibling of that, which is your device_content. Hope it helps. --Erik On 12/24/07, jody [EMAIL PROTECTED] wrote: hi all, I'm new to the list and new to jQuery, so I hope you can bear with me. I'm having a problem getting a specific div to hide without hiding similarly classed divs. The HTML looks something like this: div class=device_header h2Device Name/h2 ul lispan class=collapse_device_spana class=collapse_device-/ a/span /li /ul /div div class=device_content ---Device Information--- /div The jQuery I'd like to use looks like this: $('.collapse_device').click(function(){ $(this).next('.device_content').hide() }); If I write it as: $('.collapse_device').click(function(){ $('.device_content').hide() }); That works, but closes all the .device_content classes on the page and there could be, depending on the view, anywhere from 1-20 or more .device_content classes on the page. So, what am I doing wrong with (this).next and/or is there a better way to do what I'm trying to do? I've read around in the forums here and tried different methods but none seem to get at this exact problem. I've deduced that it may be to do with next requiring siblings--but I can't find clear documentation on just how strictly jQuery interprets the word sibling--if strictly, e.g. anchors are only siblings of anchors, then I can see the problem in that an anchor can't recognize the .device_content div as its sibling. But then I wonder if I'm thinking too hard about it? Thanks in advance, jody
[jQuery] Re: clicking on row vs. clicking on link in that row
While returning false will stop the event from propagating, it will also prevent the default action from occurring, which isn't necessarily desirable. In this case it might not matter, but in general, event.stopPropagation() is the right way to stop the event from propagating. Returning false does both event.stopPropagation() and event.preventDefault(). --Erik On 12/21/07, Shawn [EMAIL PROTECTED] wrote: You probably need to return false from your click handlers // highlight rows, load details $(#myTable tr).mouseover(function() { $(this).addClass(over);}).mouseout(function() { $(this).removeClass(over); }).click(function(){ $(this).addClass(thisRow).siblings().removeClass(thisRow); var job = $(this).attr('id') var details = (job + '.htm') $(#console).load(details); return false; }); $(#myTable a.ackn).click( function(){ $(this).parents('tr').hide(); return false; }); That *should* take care of things for you... Shawn rolfsf wrote: I've set up a simple action when a user clicks on a row in a table. (highlight the row, load some details via ajax into a div) However, in one column of the table I've got a link/button that, when clicked, will hide that row. If clicked, I don't want to highlight the row or load it's details. How do I distinguish between the two? // highlight rows, load details $(#myTable tr).mouseover(function() { $(this).addClass(over);}).mouseout(function() { $(this).removeClass(over); }).click(function(){ $(this).addClass(thisRow).siblings().removeClass(thisRow); var job = $(this).attr('id') var details = (job + '.htm') $(#console).load(details); }); // hide a row after acknowledgement $(#myTable a.ackn).click( function(){ $(this).parents('tr').hide(); }); thanks, r.
[jQuery] Re: creating own callback
I doubt that will work. There need not be anything particularly jQueryish about preloading images, but if you want to stick it under $, maybe something like: jQuery.extend({ preloadImage: function(imagePath,callback) { var image = new Image(); if(jQuery.isFunction(callback)) image.onload = callback; image.src = gfx/+imagePath; } }); --Erik On 12/21/07, Jake McGraw [EMAIL PROTECTED] wrote: I'm sure there's a more sophisticated way of doing this, but functions can be passed around like any other variable type in JavaScript, so: jQuery.extend({ preloadImage: function(imagePath,callback) { jQuery(img).attr(src, gfx/+imagePath); callback(); } }); Should do the trick. - jake On Dec 21, 2007 3:11 PM, Eric Teubert [EMAIL PROTECTED] wrote: Hi, I spend some time in browsing through the documentation but I didn't find anything about creating own functions with callback- functionality. How do I do this? What I want to do: Write a function that preloads an image and returns a callback when the image is loaded. It looks like jQuery.extend({ preloadImage: function(imagePath) { jQuery(img).attr(src, gfx/+imagePath); } }); $.preloadImage(example.gif ); But how have I to edit the first part when I want the second to look like the following? $.preloadImage(example.gif, function() { alert(Preloading finished); }); Thanks!
[jQuery] Re: clicking on row vs. clicking on link in that row
Maybe try: // hide a row after acknowledgement $(#myTable a.ackn).click( function(e){ e.stopPropagation(); $(this).parents('tr').hide(); }); See also: http://docs.jquery.com/Events_(Guide)#event.stopPropagation.28__.29 --Erik On 12/21/07, rolfsf [EMAIL PROTECTED] wrote: I've set up a simple action when a user clicks on a row in a table. (highlight the row, load some details via ajax into a div) However, in one column of the table I've got a link/button that, when clicked, will hide that row. If clicked, I don't want to highlight the row or load it's details. How do I distinguish between the two? // highlight rows, load details $(#myTable tr).mouseover(function() { $(this).addClass(over);}).mouseout(function() { $(this).removeClass(over); }).click(function(){ $(this).addClass(thisRow).siblings().removeClass(thisRow); var job = $(this).attr('id') var details = (job + '.htm') $(#console).load(details); }); // hide a row after acknowledgement $(#myTable a.ackn).click( function(){ $(this).parents('tr').hide(); }); thanks, r. -- View this message in context: http://www.nabble.com/clicking-on-row-vs.-clicking-on-link-in-that-row-tp14464501s27240p14464501.html Sent from the jQuery General Discussion mailing list archive at Nabble.com .
[jQuery] Re: Plugin for code highlighting and row numbering?
Chili is probably your best bet. I whipped up a little example that does a little post processing to add line numbers: http://erikandcolleen.com/erik/projects/jquery/chililineno/ There might already be an option for it in Chili, and there's probably a smother way to apply it than I'm doing, but I'm in a hurry, and what I did works, so it should at least get you started. It would probably be nice if this was just an option to Chili. Only tested on FF2/Mac. --Erik On 12/20/07, Shawn [EMAIL PROTECTED] wrote: I know I saw something a while ago, but can't seem to see it on the Plugins page. I'm looking for a plugin that can do syntax coloring and row numbering for when I need to post code samples to my web pages. The best I've found so far is Chili for the syntax coloring. But it's samples don't seem to indicate it can do row numbering. Any tips? (apologies if I'm just being blind). Shawn
[jQuery] Re: Stupid little game :)
Fun, thanks for sharing :) --Erik On 12/19/07, Stefan Petre [EMAIL PROTECTED] wrote: Hi, I did a small game (it was a test for a client), about 6kb of code. http://www.eyecon.ro/slotmachine/ Stefan
[jQuery] Re: animation: sequential showing / hiding : how-to?
A google search for jquery fxqueue also turns up these: http://erikandcolleen.com/erik/jquery/fxQueue/ http://brandonaaron.net/jquery/plugins/fxqueue/ Not sure if they'll work with newer versions of jQuery, but maybe worth checking out. --Erik On 12/17/07, pixeline [EMAIL PROTECTED] wrote: thanks that 's excellent! i'll see if i can turn that into a plugin, maybe as an optional argument to the show function On 17 déc, 04:22, wick [EMAIL PROTECTED] wrote: Here's the method I use on my site (modified a bit to fit your example), there's probably a better way, but my version is pretty clean: function showitems(i,max) { if (i = max) { $('div.items:eq('+i+')').show('slow',function() { showitems(+ +i,max) }); } } $(function() { showitems(0,$('div.items').length); }); It's a neat effect, I use it on my site CarComplaints.com for instance here:http://www.carcomplaints.com/Ford/Focus/2001/ On Dec 16, 6:15 pm, Alexandre Plennevaux [EMAIL PROTECTED] wrote: hi! i'm displaying a series of graphical items in one command: $('div.items).show(slow); now, it was suggested by my mate that they appear one after the other, according to, say, their order of appearance in the html markup. of course i could use the callback of each show so taht the next one only start when current is finished animating, but i don't know in advance the amount of divs there will be so i'm kind of stuck on how to achieve that. Has anyone achieved something like that? Any clue would be useful. Thank you, -- Alexandre
[jQuery] Re: Shared variables, events, and namespaces...
If you're just looking to keep from polluting the global namespace, you can wrap all of your code in a closure. Lots of info here: http://www.google.com/search?q=javascript+closures For example (untested): (function() { var ele = '#foo'; $(document).ready(function() { $(ele). // ... Do something with 'ele'... }); $(window).load(function () { $(ele). // ... Do something with 'ele'... }); })(); Then ele will just be available for the scope of your closure. Also, if you really are doing something like your example, you might as well cache the jQuery object instead of the selector to save having to look it up twice. A good convention is to start variable names that point to a jQuery object with $, like so: (function() { var $ele = $('#foo'); $(document).ready(function() { $ele. // ... Do something with 'ele'... }); $(window).load(function () { $ele. // ... Do something with 'ele'... }); })(); Hope it helps. --Erik On 12/13/07, Micky Hulse [EMAIL PROTECTED] wrote: Just wondering what would be the best way to handle shared variable(s) between different events... for example: var ele = '#foo'; $(document).ready(function() { $(ele). // ... Do something with 'ele'... }); $(window).load(function () { $(ele). // ... Do something with 'ele'... }); To me, the above seems a little sloppy... Is there a good way to contain the variable ele within it's own (relevant) namespace? Maybe I should be learning/reading about classes (OOP) and jQuery? Am I thinking too hard about this? :D I would greatly appreciate tips and/or suggestions. Have a great day/night! Cheers, Micky
[jQuery] Re: Cross domain photo gallery using get().
Hi Andy, Neat idea. What you want for remote data is JSONP, which just requires that your server produce a chunk of javascript that calls a function with a specified name and passes in your data as a JSON block. So instead of generating an HTML fragment, your data.cfm would take a parameter called jsoncallback, and generate code like: value of jsoncallback paramater({ data: my html fragment}); Then in jQuery you do: $.getJSON(http://www.commadelimited.com/code/whiskerino/data.cfm?jsoncallback=? ,{ username:options['username'], size:options['size'] }, function(data){ $targetDiv.html(data.data).cycle('fade'); }); However, having said all that, since your script is already a remote JavaScript, my suggestion is just to make your js file be dynamic and include the data in it directly. Then your users could just specify their options in the url to your javascript file, like so: script language=javascript src=http://www.commadelimited.com/code/whiskerino/whiskerino.js?username=creoledivID=theDiv type=text/javascript/script And you would generate a script with the proper data already included directly in the script. Something like (in your generated whiskerino.js): $(document).ready(function(){ $('#value of divID parameter').html(everything you currently have in data.cfm).cycle('fade'); }); Or if they didn't supply a username, you could render an error message instead: $(document).ready(function(){ $('#value of divID parameter').html('div style=color: redPlease indicate your Whiskerino moniker./div').cycle('fade'); }); Also, if you don't do it like I'm suggesting, I suggest that you at least wrap the whole thing in a function instead of requiring a global object called options. In whiskerino.js have something like: function whiskerino(options) { $(document).ready({ /* your code */ }); } And then your users include your your script and call your function and pass in their options: !-- start: copying here -- script language=javascript src= http://www.commadelimited.com/code/whiskerino/whiskerino.js; type=text/javascript/script script type=text/javascript !-- whiskerino({ username:'creole' //,size:'m' // options are t, s, m, l or o | defaults to 'm'. // ,divID:'whiskerino', // optional, but will look for a div called 'whiskerino' }); //-- /script !-- end: copying here -- But the dynamic script way that I suggested would fix that too. Hope it helps. --Erik On 12/8/07, Andy Matthews [EMAIL PROTECTED] wrote: I'm participating in an event in which you post photos of yourself each day ( http://www.whiskerino.org/2007/creole/). The organizer of the event created RSS feeds for each participant. I thought it would be fun, and a good challenge to write a photo gallery using the Cycle plugin that could be used by any of the participants (http:// www.commadelimited.com/code/whiskerino/slideshow.cfm). It works great on my server, but I mistakenly assumed that the local reference data.cfm (the file that does the work) made in the JS file would always be made on my server. I just tried it locally and I'm getting the dreaded cross domain XmlHttpRequest error. I want this to work without the user have to install any code, or even have a hosting company that offers a scripting language. I wonder now if this is even possible. On data.cfm, I'm using ColdFusion to read in the RSS feed, then I'm looping over the feed and outputting the contents into div tags. You can see the results here: http://www.commadelimited.com/code/whiskerino/data.cfm Can any of you suggest an alternate method that would work?
[jQuery] Re: A 5 line script that doesn't work in IE
To check if an element has a particular class: $(...).is('.theClass'); To add a class to an element: $(...).addClass('theClass'); To remove a class: $(...).removeClass('theClass'); See also: http://docs.jquery.com/Traversing/is#expr http://docs.jquery.com/Attributes/addClass#class http://docs.jquery.com/Attributes/removeClass#class http://docs.jquery.com/Attributes/toggleClass#class See if those help. Good luck. --Erik On 12/1/07, Gordan [EMAIL PROTECTED] wrote: I'm loosing my mind over this :-( http://www.writesomething.net/users/ (show classical users list link) I have a few lines of code which are extremly simple and work as expected in FF, but IE is refusing to cooperate :-( I tried literally everything but it just returns the expected identifier, string or number error. Please help, this has to be some simple bug that I'm overseeing :- ( thank you here's the complete code, and I use the latest 1.2.1 jQuery: (IE says that the error is on the 3rd line) function change_users_display() { if ($('#users').attr('class') == 'users_cloud') { $('#users').attr({class: ''}); $('#change_users_display_classical').show(); $('#change_users_display_cloud').hide(); } else { $('#users').attr({class: 'users_cloud'}); $('#change_users_display_classical').hide(); $('#change_users_display_cloud').show(); } return true; }
[jQuery] Re: Passing extra data to AJAX handler functions
You could wrap your real callback in an anonymous function that adds the parameters that you want. Maybe something like (untested): $.post('/ajax/asset/insert', { folder_tid : lastUploadedFolderTID, link : linkQueue[id] }, function(data, status) { handleAddLinkComplete.call(this, data, status, 123); }, 'json'); Good luck with it. --Erik On 11/27/07, Rob Barreca [EMAIL PROTECTED] wrote: I commonly want to pass an ID or some other information I know to an AJAX success handler. $.post('/ajax/asset/insert', { folder_tid : lastUploadedFolderTID, link : linkQueue[id] }, handleAddLinkComplete, 'json'); In this example, I want to pass an ID to handleAddLinkComplete function. I know I can do the following, but they seem crufty to me. 1. I can set a global variable with the link ID, but what if I have a bunch of post calls, there are synchronous issues (I know I can do async : false too) 2. I could have my /ajax/asset/insert callback return the link ID back to me in the response, but it seems silly if I already know it. I would love to do something like... $.post('/ajax/asset/insert', { folder_tid : lastUploadedFolderTID, link : linkQueue[id] }, { callback : handleAddLinkComplete, arguments : [123] }, 'json'); or something. What is the best way here or is my dream a reality? Cheers, -Rob
[jQuery] DateJS: Robust Date manipulation library
Hello all, This came through my feed reader this morning, and I thought it looked like the kind of thing jQuerians might enjoy: http://www.datejs.com/ It's a Date library with lots of parsing capabilities and jQuery style chainable syntactic sugar. It's ~25k minified (!), so it's probably not for everyone, but I can imagine a lot of places where something like this would be very helpful. Cheers! --Erik
[jQuery] Re: $('.class1,.class2').filter(':first') always finds first .class1
Your issue doesn't actually have anything to do with the filter, it's the selection. $('.class1,.class2') selects all class1, then all class2. So even if class2 appears before class1, class one will still get selected first (since you specified it first in the selector), and your filter will return it. I suggest you apply the same class to all elements that you want to select from. If nothing else, you could do: $('.class1,.class2').addClass('class1_or_class2'); $('.class1_or_class2').filter(':first')...; And that second line could be simplified to: $('.class1_or_class2:first')...; Hope it helps. --Erik On 11/5/07, Pyrolupus [EMAIL PROTECTED] wrote: Basically, what I want to do is find the first element that matches either class1 OR class2. However, using the syntax from the subject line: var $jqElem = $('.class1,.class2').filter(':first'); $jqElem is always the first element that has class1 (i.e., the first class specified), rather than the first element for the whole selector. E.g., using the above on the following: input type=text id=elem1 class=class2 / input type=text id=elem2 class=class1 / it is getting elem2. Am I using the wrong syntax? I also tried $ ('.class1').add('.class2').filter(':first'), but I get the same result. Thanks, Pyro
[jQuery] Re: $('.class1,.class2').filter(':first') always finds first .class1
Your issue doesn't actually have anything to do with the filter, it's the selection. $('.class1,.class2') selects all class1, then all class2. This totally explains why I have the issue, and I thank you for describing it. I expected the select element statement to behave something like, className ~= /^(?:class1|class2)$/, but it really operates more like, (.class1).push(.class2). In fact, there's even a comment about this in the docs: http://docs.jquery.com/Selectors/multiple#selector1selector2selectorN Note order of the dom elements in the jQuery object aren't necessarily identical. However, this seem to do what you want, albeit probably a little slower: $('*').filter(function() {return $(this).is('.class1,.class2');})...; Though you should probably use something a little more specific than * as the initial selector. Maybe ':input' to search all inputs, or '#myForm *' or '#myForm :input' to only search children of your form. Hope it helps. --Erik
[jQuery] Moo based Calendar widget
Here's a very slick calendar widget built on mootools: http://moomonth.com/ Demo here: http://moomonth.com/demo/index.html It looks like it also has a number of handy additions to the Date object that might be useful outside of mootools: http://moomonth.com/docs/index.html --Erik
[jQuery] Re: Alternatives to dom ready() for running Jquery code
Move your javascript to the bottom of the page, right before /body, or use $(window).load(...) instead, if you can handle your javascript not running until all of your external resources (read: images) have loaded. I think this should be fixed soon. --Erik On 11/1/07, Brett [EMAIL PROTECTED] wrote: Hey all, I've ran into a problem where I get code that runs occasionally on IE6 and IE7. It's working fine in Firefox, of course :/ The code I have is: $(document).ready(function(){ //$(function() headline_count = $(div.headline).size(); $(div.headline:eq(+current_headline+)).css('top','5px'); headline_interval = setInterval(headline_rotate,9000); //time in milliseconds $('#scrollup').hover(function() { clearInterval(headline_interval); }, function() { headline_interval = setInterval(headline_rotate,9000); //time in milliseconds headline_rotate(); }); function headline_rotate() { current_headline = (old_headline + 1) % headline_count; $(div.headline:eq( + old_headline + )).animate({top: -205},slow, function() { $(this).css('top','210px'); }); $(div.headline:eq( + current_headline + )).show().animate({top: 5},slow); old_headline = current_headline; } // End of headline code }); but I guess the important part is: $(document).ready(function(){ }); Ready just doesn't seem to fire correctly for me all the time. Looking at a previous post which kind of covered this : http://groups.google.com/group/jquery-en/browse_thread/thread/ae511652b94433fa/819f718c882c9ba2?lnk=gstq=ready()#819f718c882c9ba2 They couldn't get a definate answer neither. I just want to ensure that the headlines do appear all the time, at the moment I'm left with a white box sometimes. live link to test is: http://cressaid.brettjamesonline.com/bvci/
[jQuery] Re: limit to only jpeg when file upload
Untested: form method=POST action=... input id=file name=file type=file /form $('form').bind('submit', function() { var ext = $('#file').val().split('.').slice(-1).toLowerCase(); if(ext != 'jpg' ext != 'jpeg') { alert('JPEG Only'); return false; } }); --Erik On 10/31/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: so where to attach the code? in the onClick of submit button? On Nov 1, 12:04 am, Giovanni Battista Lenoci [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] ha scritto: Hi, I'm using this to upload file: input id=file name=file type=file It works very well, now I'd like to find a way to check only jpeg files are uploaded, any way to do this in jQuery? Thanks. A.C. I think the only thing you can do client-side is to check the extension. $pieces = $('#file')[0].value.split('.'); $extension = $pieces[$pieces.length-1].toLowerCase(); if($extension == 'jpg' || $extension == 'jpeg') { alert('accepted'); }
[jQuery] Re: .attr(type,hidden)
See also, this thread: http://groups.google.com/group/jquery-en/browse_thread/thread/b1e3421d00104f17/88b1ff6cab469c39 --Erik On 10/29/07, Robert O'Rourke [EMAIL PROTECTED] wrote: Hi, does $(some selector).attr(type,hidden) work for anyone? I'm getting this in firebug: [Exception... 'type property can't be changed' when calling method: [nsIDOMEventListener::handleEvent] nsresult: 0x8057001e (NS_ERROR_XPC_JS_THREW_STRING) location: unknown data: no] Cheers, Rob
[jQuery] Re: jquery plugin + problem with return for this element
Despite the fact that you code is a bit of a mess, your problem is just that since you aren't defining the variable callback with var callback = ..., it's being made a global variable, and as a global variable, each time you call $(...).test1(...), you're overwriting callback. Same for ttt. Adding var before callback and ttt fixes the problem. Good luck with it. --Erik On 10/24/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: You're not getting 'this' correct. Where you set 'b', 'this' is the jQuery object, not an element. So 'b' is a jQuery object that wraps three dom elements. Here's a hint: (function($) { $.fn.test2 = function(color) { // 'this' is the jQuery object return this.each(function() { // 'this' is a DOM element var $el = $(this); $el.bind('click', function() { // this is the DOM element again $el.css('color',color); } } } })(jQuery); http://bynight.me.uk/jquery/mike.php Still its not okay, but... When I use b.bind('click', function() { b.css('color',color);} it works fine, but when I try: callback = function(data) { b.css('color',color); } ttt= function() { callback(); } b.bind('click',ttt); I have result as you see on my page... ... To be more specific... I want use my plugin like that: callback = function() { ...} $('#something').test('option',callback); or $('#something').test('option',function() {...}); thats why I want to have my function (ttt or callback) outside of b.bind(..) Thanks. Michael
[jQuery] Re: Gotcha in the ajax call
That parameter is added when you set the 'cache' property to false. Are you doing that? --Erik On 10/21/07, M. A. Sridhar [EMAIL PROTECTED] wrote: When making a GET call via jQuery.ajax, jQuery 1.2.1 adds a URL parameter named '_' (the single underscore character) whose value is the current time stamp. I'm not sure I understand why, and in any case, this caused me some grief when I tried to use it in a Facebook app. The reason is that the Facebook API requires a signature parameter as part of each request, and this parameter is basically the MD5 hash of the rest of the parameters. So the extraneous jQuery parameter was not being accounted for in my code, causing Facebook to complain about an incorrect signature. Perhaps someone can explain the need for this parameter. And perhaps it can be made optional in a future release? Just my $0.02. Regards.
[jQuery] Re: prevent checkbox to check when click
.click(...) and .bind('click', ...) should do the same thing. What version of jQuery are you using? This also works for me, again on FF2/Mac: $(':checkbox').bind('click', function(e) { this.blur(); e.preventDefault(); }); --Erik On 10/18/07, james_027 [EMAIL PROTECTED] wrote: is that different if I use .click() instead of .bind()? because it doesn't work for me thanks On Oct 19, 1:57 pm, Erik Beeson [EMAIL PROTECTED] wrote: Just return false from a click handler. The box will be focused, which will change the way it looks a little, so you may also want to blur it. Something like: $(':checkbox').bind('click', function() { this.blur(); return false; }); Tested on FF2/Mac. --Erik On 10/18/07, james_027 [EMAIL PROTECTED] wrote: hi, how do i prevent the checkbox to be check when click if it doesn't meet certain requirements? Thanks
[jQuery] Re: Case-insensitive version of :contains(text) ?
You could add your own expression for it (tested on FF2/Mac): jQuery.extend(jQuery.expr[':'], { containsIgnoreCase: (a.textContent||a.innerText||jQuery (a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())=0 }); Usage: $('...:containsIgnoreCase(foo)'); Or you could use a filter that would work basically the same way. --Erik On 10/13/07, RichUncleSkeleton [EMAIL PROTECTED] wrote: The selector :contains(text) appears to be case sensitive (though there's no mention of this in the jQuery docs). Is there a case insensitive version?
[jQuery] Re: How to suck web content from an iframe to a div
IIRC, sub-domains can also be made to work if all pages involved set the same document.domain But back to the OP, your iframe can deal with scrolling itself if you set its size in the containing page, and that you can do cross-domain. Maybe I don't quite get what you're trying to do... --Erik On 10/19/07, Mike Alsup [EMAIL PROTECTED] wrote: Julian, Getting the contents from an IFrame served from the same domain works fine. The security only kicks in for x-domain content. Mike On 10/15/07, juliandormon [EMAIL PROTECTED] wrote: Thanks Mike, That makes sense. And what if it was the same domain? This is also the case with our new site. I should have been more specific. I apologize. malsup wrote: Julian, You cannot access the contents of an IFrame which is sourced from a different domain. This is part of the browser's cross-domain security model. Mike On 10/15/07, juliandormon [EMAIL PROTECTED] wrote: Hoping anyone can help. I use a custom scroll bar jquery plug-in which requires the content to be within a DIV. Some of the content I want to load is from other web sites. I am pretty sure it is possible to load the content into a hidden iframe and then, once it has finished loading, suck the data in the iframe into my div and then apply my scrollbar plugin to the newly fitted div. What's the proper method and plug-ins used to achieve this please? What are some of the pitfalls in doing this, if any? -- View this message in context: http://www.nabble.com/How-to-suck-web-content-from-an-iframe-to-a-div-tf4630767s27240.html#a13223056 Sent from the jQuery General Discussion mailing list archive at Nabble.com. -- View this message in context: http://www.nabble.com/How-to-suck-web-content-from-an-iframe-to-a-div-tf4630767s27240.html#a13223518 Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: prevent checkbox to check when click
Just return false from a click handler. The box will be focused, which will change the way it looks a little, so you may also want to blur it. Something like: $(':checkbox').bind('click', function() { this.blur(); return false; }); Tested on FF2/Mac. --Erik On 10/18/07, james_027 [EMAIL PROTECTED] wrote: hi, how do i prevent the checkbox to be check when click if it doesn't meet certain requirements? Thanks
[jQuery] Re: filter not working when expression contains spaces
This is the expected behavior. The selector '.myClass a' describes an A tag being a descendant of a tag with the class myClass. is() doesn't work on a relationship as the result is ambiguous. To check if this element is an A tag that is a descendant of of a tag with class myClass, maybe try: if($(this).filter('a').parents('.myClass').length 0) {...} Or, in your case: if($(target).is('a')) { if($(target).parents('.myClass').length 0) { } if($(target).parents('.myOtherClass').length 0) { } } Or, if you just want to check if this is a child of an element with a particular class, you could do: var $parent = $(target).parent(); if($parent.is('.myClass')) {...} if($parent.is('.myOtherClass')) {...} --Erik On 9/26/07, duff [EMAIL PROTECTED] wrote: Hi all, I have started to use Jquery a couple month ago, and i really love the framework. I am currently working on an event delegation plugin, attaching generic event to the document and applying filters to the target element to determine if an event should be applied. I have however noticed some weird behavior for the .is() and .filter() function : I am using the latest jquery version 1.2.1 and am having some troubles with the filter function. If you use filter with an expression containing a space ( '.myClass a' for example), nothing is filtered at all. $('*').filter('.myClass a' ); returns all the nodes on the page. Is it the expected behaviour ? Is there other ways to efficiently check if a given node matches a given rule ? document.addEventListener('click', function(target){ if $(target).is('.myClass a'){ //do sth } if $(target).is('.myOtherClass a'){ //do sth else } } ); Thanks
[jQuery] Re: Aaron Gustafson has a great ALA-Article on (Content-)Image Alignment and Consistency
Is there a reason you didn't replace this.getElementsByTagName? --Erik On 9/27/07, Remy Sharp [EMAIL PROTECTED] wrote: If you're talking about the If I Told You You Had a Beautiful Figure... article, here you go: function FigureHandler(g, h) { if (typeof(h) !== 'object') { var h = { '75-100' : 'full-col', '67-75' : 'three-quarters-col', '50-67' : 'two-thirds-col', '34-50' : 'half-col', '25-34' : 'third-col', '0-25' : 'quarter-col' }; } var i = 'div.figure'; if (typeof(g) == 'string') i = '#' + g + ' ' + i; function init() { $(i).each(function () { var b = this.getElementsByTagName('img')[0].width; var c = parseInt($(this.parentNode).css('width')); var d = Math.ceil(b/c*100); var e, col_class; for (var f in h) { e = f.split('-'); if(d e[0] d = e[1]) { col_class = h[f]; break; } } $(this).addClass(col_class); $(this.getElementsByTagName('p')).each(function () { this.style.width = b+'px'; }); }); } init(); } $(function (){ new FigureHandler( 'main', { '0-27': 'small', '27-100': 'large' } ); new FigureHandler( 'extras', { '0-50': 'potato', '50-100': 'tomato' } ); }); On Sep 25, 9:10 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Anyone already has a similar approach based on jQuery? If so, is there a chance to share it? Regards, Erik
[jQuery] Re: functions after $.get work strange
$.get is asynchronous, meaning the call to $.get returns immediately, even before the callback has happened. To answer your specific question, setting a variable who's scope is outside the callback is as easy as defining the variable outside the callback: var foo; $.get(..., function() { foo = ...; }); But to address the actual problem that you're having, here are the order in which your functions are being executed: Enter isTracked Enter $.get Leave $.get Leave isTracked Enter callback Leave callback So you see, by the time isTracked returns, your callback hasn't executed yet, which is why you see null the first time, and the first value the second time. To do what you want to do, you need to step back a level. Presumably, you do something with the return value from isTracked, so you don't want isTracked to return until it has said value. Say you have: var tracked = isTracked(code); // do something with tracked. To do what you want, you need to pass a callback to isTracked that will get called once the data is available. In your case, you could just pass the callback along to $.get. So your setup might look something like: function isTracked(personcode, callback) { $.get('trackstudent/istracked.php', {'personcode': personcode}, callback); } isTracked(code, function(tracked) { // do something with tracked, exactly as you would have done above. }); This is just part of how JavaScript works, and part of why anonymous functions are so prevalent. Hope it helps. --Erik On 9/27/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Im trying to set somehow variable inside of $.get callback and get outside this callback. Im doing it in this way (because I dont know any other way): function isTracked(personcode) { ret='false'; // it should return string 'true' or 'false' $.get('trackstudent/istracked.php',{'personcode': personcode}, function(data) { //because I dont know how to set variable inside of callback and get outside if ($('span.tempvar').length==0) $('body').append('span class=tempvar style=display: none'+data +'/span'); else $('span.tempvar').html(data); // now I should have at the end of body a new element span alert('1: '+$('span.tempvar').html()); }); //get variable outside $.get callback ret=$('span.tempvar').html(); alert('2: '+ret); //return ret; //ret have proper value } ... when I run this function first time I have two alert messages (data in $.get is 'true'): first: 1: true second: 2: null //second should be: 2: true; when I run second time I have (data in $.get is 'false'): first: 1: false second: 2: true //old value! (dont know why!) //second should be false; When Im checking genereted by javascript source code I see my span How it is possible?! or maybe you have another solution how to set variable inside of $.get callback and get outside TIA Michael
[jQuery] Re: Toggling a checkbox
To check or uncheck a checkbox, assign true or false to its 'checked' property (untested): $('#myCheckbox')[0].checked = true; or $('#myCheckbox').attr('checked', true); But it looks like you're trying to enable/disable them, in which case you probably want $(...).attr('disabled', 'disabled'); and $(...).removeAttr('disabled'); --Erik On 9/27/07, voltron [EMAIL PROTECTED] wrote: How would one toggle a checkbox? This does not work: $(#postcode_all).toggle(function(){ $(#intended_postcode-0).attr(disabled, disabled); },function(){ $(#intended_postcode-0).attr(enabled, enabled); }); Thanks
[jQuery] Re: Alternative syntax?
You'll learn to love anonymous functions. And eventually, you'll even learn to love closures: (function($) { // do something })(jQuery); I guess cleanliness is relative. It looks pretty clean to me. The goal of anonymous functions is to be able to pass around chunks of code to be executed later. How would you propose a cleaner syntax look? --Erik On 9/26/07, A32 [EMAIL PROTECTED] wrote: I find the following example very dirty syntax: $(document).ready(function(){ alert(Document is ready) $(a).click(function(){ alert(Clicked); }); }); With all those ) and } I don't know if I'm coming or going.. Is there an alternate syntax I can use? Do I *have* to use the function() all the time or is there a different way? I've been away from JavaScript for a long time but never seen anything like that :-) If there's no way around it, does anybody know of a javascript preprocessor that I could use a cleaner syntax while developing? Thanks!
[jQuery] Re: OT Changing S=style sheet with javascript or jquery?
A google search for 'jQuery stylesheet switcher' turns up: http://kelvinluck.com/article/switch-stylesheets-with-jquery --Erik On 9/27/07, Eridius [EMAIL PROTECTED] wrote: http://demo.sugarondemand.com/sugarcrm_os/index.php?action=indexmodule=Home if you click on the blocks of color at the top, i don't know if they are just change the css on the fly or completely loading a new css file. Is it possible to load a different css file on the fly with javascript itself or with jquery easier? -- View this message in context: http://www.nabble.com/OT-Changing-S%3Dstyle-sheet-with-javascript-or-jquery--tf4532015s15494.html#a12933318 Sent from the JQuery mailing list archive at Nabble.com.
[jQuery] Re: Attribute renaming
Rename them from what to what? To change the id of all selects, you can do: $('select').each(function() { var oldId = $(this).attr('id'); $(this).attr('id', oldId.substring(0, oldId.lastIndexOf('-'))); }); I'm still not sure what you actually want to do though. --Erik On 9/26/07, voltron [EMAIL PROTECTED] wrote: I am trying to rename the ids and name attributes On Sep 26, 10:06 am, Erik Beeson [EMAIL PROTECTED] wrote: What are you trying to accomplish? --Erik On 9/26/07, voltron [EMAIL PROTECTED] wrote: I have tags like this: select id=academic_from_month-0 select id=academic_till_month-0 since the ids are variable in length, I would have to find out where the lastindex() of - is remove that and replace it it with the new value. My problem is the syntax, is there some kind of Jquery way to do this? Thanks
[jQuery] Re: Attribute renaming
How about something like (untested): $('#container').clone().attr('id', 'container'+idx).find('*').each(function() { this.name += idx; this.id += idx }).end().appendTo(...); How you deal with 'idx' is up to you. So that's: select the element with ID 'container', clone it, update the clone's id, select all of the clone's descendant elements, update their names and IDs, go back to the clone and append it to where ever you want it to show up. --Erik On 9/26/07, voltron [EMAIL PROTECTED] wrote: Hi Erik, I am cloning a DIV container full of elements( selects, inputs and buttons), they all inherit the name of the original element, but to differentiate between all, I want to rename all the clones attributes sequentially, example div name= container input name=color input name=house /dv if I clone the whole container, the names should be: div name= container input name=color input name=house /dv div name= container1 input name=color1 input name=house1 /dv ans so forth Thanks On Sep 26, 12:57 pm, Erik Beeson [EMAIL PROTECTED] wrote: Rename them from what to what? To change the id of all selects, you can do: $('select').each(function() { var oldId = $(this).attr('id'); $(this).attr('id', oldId.substring(0, oldId.lastIndexOf('-'))); }); I'm still not sure what you actually want to do though. --Erik On 9/26/07, voltron [EMAIL PROTECTED] wrote: I am trying to rename the ids and name attributes On Sep 26, 10:06 am, Erik Beeson [EMAIL PROTECTED] wrote: What are you trying to accomplish? --Erik On 9/26/07, voltron [EMAIL PROTECTED] wrote: I have tags like this: select id=academic_from_month-0 select id=academic_till_month-0 since the ids are variable in length, I would have to find out where the lastindex() of - is remove that and replace it it with the new value. My problem is the syntax, is there some kind of Jquery way to do this? Thanks
[jQuery] Re: Using .children recursively
This will find all descendants: $(this).find('*'); --Erik On 9/26/07, voltron [EMAIL PROTECTED] wrote: I am trying to get all the children of a node, apart from adding .children() for every generation, is there one call that gets all recursively? this is what I´m doing at the moment $(this).children().children().removeAttr(name);
[jQuery] Re: Parent Child Selectors + bind
Also, your initial selector can be simplified to: $(#id1 :text) --Erik On 9/26/07, Remy Sharp [EMAIL PROTECTED] wrote: You're binding to 'onfocus' when it should be 'focus': $(#id1 [EMAIL PROTECTED]).bind(focus, foo); On Sep 26, 8:35 am, Anjanesh [EMAIL PROTECTED] wrote: Hi I cant get this seem to work $(#id1 [EMAIL PROTECTED]).bind(onfocus, foo); Is there something wrong with the argument ? Thanks
[jQuery] Re: cannot retrieve elements with xpath
If you're using jQuery 1.2 or later, you need the XPath plugin. See here: http://docs.jquery.com/Release:jQuery_1.2#XPath_Compatibility_Plugin --Erik On 9/26/07, julio [EMAIL PROTECTED] wrote: it doesn't work for me. I have used $(function() { and $(document).ready(function() { but nothing works I'm using firefox 2.0.6 On 26 Set, 13:33, Remy Sharp [EMAIL PROTECTED] wrote: You need to wrap the jQuery in a 'ready' method - otherwise your JS is running before the DOM is ready: $(function () { $(//[EMAIL PROTECTED]'2']).hide(); $(//[EMAIL PROTECTED]'3']).hide(); }); Making this change works. On Sep 26, 10:45 am, julio [EMAIL PROTECTED] wrote: Hi, I have this simple html page: html headtitleA test page/title/head script type=text/javascript src=jquery.js/script body script $(//[EMAIL PROTECTED]'2']).hide(); $(//[EMAIL PROTECTED]'3']).hide(); /script h1 myattr=1test-row1/h1 another row h1 myattr=1test-row2/h1 img myattr=2 src=pic1.png / img myattr=2 src=pic2.png / table myattr=3 tr myattr=4 td myattr=5test/td /tr tr myattr=4 td myattr=5test/td /tr /table /body /html and I would like hide elements retrieved via xpath like in script/. But it doesn't work Why? Have you any idea? Thanks, Julio