[jQuery] Re: Unbind by Function Reference

2009-03-19 Thread ricardobeat

Since jQuery 1.3 you can use the live() function, so you don't need to
rebind the events.

Just set $('table caption a').live('click', addItemFinal) once in $
(document).ready() and all anchors added to the doc afterwards that
match this selector will fire the function on click.

live() uses what is called 'event delegation':
http://www.robertnyman.com/2008/05/04/event-delegation-with-javascript/

In your code, you could simply use $('table caption a').unbind
('click') if there are no other event listeners you want to preserve.

cheers,
- ricardo

On Mar 19, 9:33 am, bart b...@ivwd.nl wrote:
 I've followed Karl Swedberg's article on rebinding events at
 learningjquery.com. The theory behind this technique is clear to me
 and I've got a working example.

 function addItemFinal()
 {
         var $href = $('table caption a').attr('href');
         var $rawmaandjaar = $href.split('');
         var $maand = $rawmaandjaar[0].split('=');
         var $jaar = $rawmaandjaar[1].split('=');

         $.get('includes/inc/ajax/fetchtable.php', { maand: $maand[1], jaar:
 $jaar[1] }, function(data)
         {
                 $('div#agendawrapper').html(data);
                 $('table caption a').unbind('click', 
 addItemFinal).bind('click',
 addItemFinal);
         });
         return false;

 }

 $('table caption a').bind('click', addItemFinal);

 The code in the function is pretty simple, it takes the href attribute
 and extracts some variables from it. With the variables it makes a GET
 request and in the callback it rebinds again.

 However is there more than one anchor in the caption and with the
 current code it just takes table caption a whereas this should be
 the actual link you clicked. I guess I should pass something to the
 function but it's used as a reference so I'm not sure how to achieve
 this...

 Someone who can help out?


[jQuery] Re: Javascript city state zipcode country component

2009-03-19 Thread ricardobeat

I'm using Maxmind's GeoLite City open-source database. It's free and
has surprising accuracy. They also have paid webservice plans with
more precise data.

http://www.maxmind.com/app/geolitecity

cheers,
- ricardo

On Mar 19, 12:06 am, Vijay Balakrishnan bvija...@gmail.com wrote:
 Hi,

 Has anyone used a stable Javascript component for city, state,zip,country ?
 Doesn't matter if it costs money as long as it is usable off the shelf and
 has the US Military Area codes too.

 I have found a few by Googling but wanted to know if PJUG users had any good
 experience with any of these components ?

 http://www.google.com/search?hl=enq=javascript+zipcode+city+state+co...

 TIA,
 Vijay


[jQuery] Re: Unbind by Function Reference

2009-03-19 Thread ricardobeat

http://docs.jquery.com/Events (Live Events)
http://docs.jquery.com/Events/live#typefn

On Mar 19, 3:35 pm, bart b...@ivwd.nl wrote:
 Thank you for your answer. With a search on the jquery site I can't
 find the documentation on how to use the function or see an example..
 Why is that?

 On Mar 19, 3:40 pm, ricardobeat ricardob...@gmail.com wrote:

  Since jQuery 1.3 you can use the live() function, so you don't need to
  rebind the events.

  Just set $('table caption a').live('click', addItemFinal) once in $
  (document).ready() and all anchors added to the doc afterwards that
  match this selector will fire the function on click.

  live() uses what is called 'event 
  delegation':http://www.robertnyman.com/2008/05/04/event-delegation-with-javascript/

  In your code, you could simply use $('table caption a').unbind
  ('click') if there are no other event listeners you want to preserve.

  cheers,
  - ricardo

  On Mar 19, 9:33 am, bart b...@ivwd.nl wrote:

   I've followed Karl Swedberg's article on rebinding events at
   learningjquery.com. The theory behind this technique is clear to me
   and I've got a working example.

   function addItemFinal()
   {
           var $href = $('table caption a').attr('href');
           var $rawmaandjaar = $href.split('');
           var $maand = $rawmaandjaar[0].split('=');
           var $jaar = $rawmaandjaar[1].split('=');

           $.get('includes/inc/ajax/fetchtable.php', { maand: $maand[1], 
   jaar:
   $jaar[1] }, function(data)
           {
                   $('div#agendawrapper').html(data);
                   $('table caption a').unbind('click', 
   addItemFinal).bind('click',
   addItemFinal);
           });
           return false;

   }

   $('table caption a').bind('click', addItemFinal);

   The code in the function is pretty simple, it takes the href attribute
   and extracts some variables from it. With the variables it makes a GET
   request and in the callback it rebinds again.

   However is there more than one anchor in the caption and with the
   current code it just takes table caption a whereas this should be
   the actual link you clicked. I guess I should pass something to the
   function but it's used as a reference so I'm not sure how to achieve
   this...

   Someone who can help out?


[jQuery] Re: Trying to animate the .before()/.after() dom action

2009-03-19 Thread ricardobeat

All I see is a brief flash at the end of the animation, not very
noticeable, both in IE and FF. I suppose there isn't a way to avoid
that as you are removing/appending the elements. Maybe fixing the
$targetNode position with position:absolute before the after/before
call, that should avoid some of the flickering.

On Mar 19, 9:28 am, ragsyboy james.wr...@gmail.com wrote:
 Hi,

 I'm trying to add animation to the .before()/.after() action on some
 dom nodes and getting visual glitches which get seriously worse on
 html 'heavy' pages.

 I've put together a quick n' dirty example here:http://jsbin.com/ahupa/edit
 If you click the down button in the first div you'll see them swap
 round with animation, then the change is reflected in the DOM.

 i'm getting the offsets of the clicked div and it's adjacent div,
 animating the difference so they slide past each other, then it
 removes the leftover styles applied by the animation, then fires
 the .before() or .after() depending on the required direction.
 But no matter what order i do this (remove styles before/after dom
 change) I always see for a split second the dom nodes swapped round
 but with the style remnants from the animation still there - meaning
 their all over the place for a second. This gets worse the heavier the
 page is.

 This is kinda hard to explain but hopefully your browser/machine is
 slow enough to show the problem in the example :S

 Any ideas? am i tackling this the wrong way?

 Thanks in advance,

 James


[jQuery] Re: Best way to select dom element ? (find or children ?)

2009-03-19 Thread ricardobeat

This is a bit more efficient:

$('.test1').change(function(){
  var test1 = $(this).val();
  var test2 = $(this).closest('li').next('li').find('select.test2').val
();
  alert(Test1: +test1+and Test2: +test2);
});

Or to avoid repeating the traversal every time:

$('#idfortheUL li').each(function(){
  var $t1 = $(this).find('select.test1'),
   $t2 = $(this).find('select.test2');
  $t1.change(function(){
alert( test1: + $t1.val() + \ntest2: + $t2.val() );
  });
});

cheers,
- ricardo

On Mar 19, 11:04 am, Jsbeginner jsbegin...@monarobase.net wrote:
 Hello,

 I'm trying to get the value of an option in a select list contained in a
 different li item...

 Here is the html code :

 ul
 lipselect class=test1
 option value=1 selected=selectedOption 1/option
 option value=2Option 2/option
 /select/p/li
 lipselect class=test2
 option value=3Option 3/option
 option value=4  selected=selectedOption 4/option
 /select/p/li
 /ul

 ul
 lipselect class=test1
 option value=1 selected=selectedOption 1/option
 option value=2Option 2/option
 /select/p/li
 lipselect class=test2
 option value=3 selected=selectedOption 3/option
 option value=4 Option 4/option
 /select/p/li
 /ul

 I would like to be able to get the text of .test2 option:selected when I
 change the value of .test1 option selected ...

 Here is the JS code I've written .:

 $(.test1).change(function(){
 var test1 = $(option:selected, this).val();
 var test2 = $(this).closest(ul).find(li  p  .test2
 option:selected).val();
 alert(Test1 : +test1+ and Test2 :+test2);

 });

 Is this the best way? or is there a better way to achieve the same result ?

 Thankyou.


[jQuery] Re: findValue

2009-03-19 Thread ricardobeat

I guess the problem is this line:

var ac = $(#operator)[0].autocompleter.findValue();

$(..)[0] gives you the first HTML Element in the object. It's not a
jQuery object anymore, so the autocompleter property doesn't exist.

IDs should be unique so that is unneeded, try changing it to

var ac = $(#operator).autocompleter.findValue();

If you had a class or other selector that returns many elements, and
you just want the first one, you'd use

$(.operator:first).autocompleter.findValue();
or
$(.operator).eq(0).autocompleter.findValue();
or
$( $(.operator)[0] ).autocompleter.findValue();
//notice the re-wrapping. this is useful if you already have the $
('.operator') object saved in a variable

cheers,
- ricardo



On Mar 19, 12:37 pm, brightdad...@googlemail.com
brightdad...@googlemail.com wrote:
 Thanks for the suggestion Lauri.

 I have tried as asuggested and still dont see anything happening.


[jQuery] Re: show hide random rows

2009-03-18 Thread ricardobeat

If you need performance, this should be it:

http://jsbin.com/uvuzi/edit

It sorts the rows using the Fisher-Yates shuffling algorithm.
Despite throwing elements around in an array, it's faster than the
pure mathematical solution because you don't need to filter out
duplicate random numbers. An even greater improvement can be made by
using the style.display property directly.

cheers,
- ricardo

On Mar 18, 4:20 pm, Scott Sauyet li...@sauyet.com wrote:
 Sean O wrote:
  Nice job. I like the logic, and the fading out of unselected rows.

  My solution was, admittedly, a quick one. It certainly wouldn't scale past
  1,000 rows or so -- especially with the majority # selected -- but if the
  10/50 number is firm, seemed to work OK.

 Yours is probably more efficient on average than mine, even at higher
 numbers, except in extreme cases.  The advantage of mine is in
 predictability.  It's going to loop through all the rows making one call
 to random() for each.

 Mine was actually a quick copy of something I recently had to do in my
 day job where this predictability was more important (to my boss) than
 average efficiency, and where the numbers were higher.  Although I coded
 this approach, I argued unsuccessfully for your approach, which is
 usually faster.

 In any case, either should work fine for the OP if the numbers are
 anything like the example given.

    -- Scott


[jQuery] Re: :visible change

2009-03-18 Thread ricardobeat

You're missing a closing parenthesis in your IF statement. Other than
that, your code works fine:

http://jsbin.com/oguqe/edit

Something else must be wrong in your page, do you have a live sample
we can look at?

It all could also be rewritten as

$('.closeEl').click(function(){
   $(this).parent().next('.itemContent').slideToggle(300);
   $(this).text( $(this).text() == '[+]' ? '[-]' : '[+]');
   return false;
});

cheers,
- ricardo

On Mar 18, 2:33 pm, s.ross cwdi...@gmail.com wrote:
 I'm stumped on a 1.3.2 change. Here is the scenario:

      // Node tree:
      // - div.groupItem
      //   - div.itemHeader
      //     - a.closeEl
      //   - div.itemContent
      //     - All the enclosed html
      //
      // When the closeEl node is clicked, act on its parent .groupItem's
      // corresponding .itemContent.

 Then the jQuery (presuming ele is the element passed to a 'click'  
 handler:

      var targetContent = $(ele).parent().siblings('div.itemContent');
      if (parseInt(targetContent.css('height'))  1) {
        targetContent.slideUp(300);
        $(ele).html('[+]');
      } else {
        targetContent.slideDown(300);
        $(ele).html('[-]');
      }
      return false;

 This works. However, the more obvious and intentional version directly  
 below doesn't work and I can't tell why.

      var targetContent = $(ele).parent().siblings('div.itemContent');
      if (targetContent.is(':visible') {
        targetContent.slideUp(300);
        $(ele).html('[+]');
      } else {
        targetContent.slideDown(300);
        $(ele).html('[-]');
      }
      return false;

 The .is(':visible') always returns true. Am I mistaking how to use  
 this? Is there a much keener way to handle it that I'm not seeing?

 Thanks,

 Steve


[jQuery] Re: Find element. How can I do this?

2009-03-18 Thread ricardobeat

The logic is all there in the source code. You can see that all of the
fieldset's children get removed and appended to the DIV - that would
include the first OL, that's why it doesn't work. This is just another
wild guess, I can't test it:

var legend = fieldset.find(':first');
var body = fieldset.find('ol:first')

var children = fieldset.children(':not(ol:first)');
var len = children.length;
if(len  1) {
  for(i = 1; i  len; i++) {
body.append(children[i]);
  } // for
} // if

Maybe it would be simpler to write your own collapse function than
adapt this plug-in, do you have a page with your html and js online?

cheers,
- ricardo

On Mar 18, 4:25 pm, shapper mdmo...@gmail.com wrote:
 Hi,

 that is what I am trying to do but by using that plugin I can:

 1. Have different CSS classes applied to collapsed and expanded
 fieldsets so I can get a toogle icons;
 2. Control the speed of collapse (this is not very important)

 The problem is that the plugin, as far as I can see, gets all the
 markup on the fieldset, places it inside a div and aplies the collapse/
 expand to the div.

 I would prefer the plugin to apply this to the ol, or even better, be
 able to specify to which element in the fieldset should this be
 applied (the collapase/expand) and the CSS classes.

 I am not expert in JQuery but the plugin seems ok ... or no?

 Thank You,
 Miguel

 On Mar 18, 6:17 pm, AnatolyG anat...@geyfman.net wrote:

  I don't have context for what you're trying to do, but if you want to
  hide the first OL that's displayed, then:

  fieldset.find(ol:eq(0)) finds it to hide it.

  but, if you just want this to be collapsable, and when clicking on the
  legend, uncollapse, wouldn't this be much easier?

        $('fieldset').each(function(index, obj){
          var $item = $(obj);
          $item.find(legend).click(function(e){
                  $item.find(ol:first).toggle();
          });
          $item.find(ol:first).hide();
        });

  If you want to do something else, explain...

  A

  On Mar 18, 8:45 pm, shapper mdmo...@gmail.com wrote:

   Sorry, I don't understand what your mean.

   Please, check the code I am using 
   in:http://www.27lamps.com/Beta/Collapse/JQuery.Collapsible-1.0.js

   The change I am trying to do is in the following lines:
       var legend = fieldset.find(':first');
       var body = jQuery(document.createElement('div'));
   //    var body = fieldset.find('ol:first')

   On Mar 18, 2:12 pm, AnatolyG anat...@geyfman.net wrote:

$(fieldset ol:eq(0)).hide()

shapper wrote:
 Hello,

 I am trying to find update a plugin to create new functionality.
 On the current version I have the following:

     var legend = fieldset.find(':first');
     var body = jQuery(document.createElement('div'));

 - How can I get the first OL element inside fieldset to use it as body
 instead of creating a new element (the div as it is currently?

 - And can I set which element should be searched (ol, ul, div, etc)
 inside the fieldset?

 Thank you,
 Miguel


[jQuery] Re: Using 1.3 this: [class!=whatever] doesn't work.

2009-03-18 Thread ricardobeat

Your example is working fine for me with 1.3.2 - $('a[class!
=whatever]'). $('a[className!=whatever]') should also work.

cheers,
- ricardo

On Mar 18, 9:26 am, will mac.tas...@gmail.com wrote:
 Hi,
 Using :not() worked great.
 Cheers
 Will

 On Mar 18, 11:09 am, T.J. Crowder t...@crowdersoftware.com wrote:

  Hi again,

  *blush* Those same docs tell us that != is also supported by Sizzle.
  Note, though, that:

      a[class!=whatever]

  ...is the same as

      a:not([class=whatever])

  ...which is *not* the same as

      a:not(.whatever)

  ...because of multiple class names.  Example:  With these links:

  a id='a' href='#'one/a
  a id='b' href='#' class='whatever'two/a
  a id='c' href='#' class='whatever blarg'three/a
  a id='d' href='#' class'blarg'one/a

  a:not(.whatever) gives you a,d, but a[class!=whatever] and a:not
  ([class=whatever]) give you a,c,d.  c is on the list because its
  value (whatever blarg) does not *exactly* match whatever.

  Perhaps that relates to why your 1.2.6 code doesn't quite work in 1.3?

  HTH, sorry for missing != support earlier.
  --
  T.J. Crowder
  tj / crowder software / com
  Independent Software Engineer, consulting services available

  On Mar 18, 10:59 am, T.J. Crowder t...@crowdersoftware.com wrote:

   Hi,

   Is there a != attribute operator?  I don't see it in either the CSS2
   or CSS3 specs.[1][2]  So I'm thinking that since jQuery 1.3 completely
   replaced the selector engine[3], there was a non-standard (but
   useful!) extension to the syntax in v1.2 that didn't get carried
   forward.

   The good news is that the docs[4] for the new selector engine, Sizzle,
   tell us it supports the :not pseudo-class, so you can use:

   $('a:not(.whatever)').click(...);

   ...to get the same effect that (I assume, never having used v1.2) the !
   = used to give you.

   [1]http://www.w3.org/TR/CSS2/selector.html
   [2]http://www.w3.org/TR/css3-selectors
   [3]http://docs.jquery.com/Release:jQuery_1.3
   [4]http://wiki.github.com/jeresig/sizzle

   HTH,
   --
   T.J. Crowder
   tj / crowder software / com
   Independent Software Engineer, consulting services available

   On Mar 18, 10:21 am, will mac.tas...@gmail.com wrote:

I'm working on a project at the moment and this [class!=whatever] has
stopped working.
In 1.2.6 I could use this fine, but in 1.3 it doesn't work.

For example, if I have two links:

a href=#Link/a

and

a href=# class=whateverLink/a

Using a click function like this:

$('a[class!=whatever]').click(function(){ //do something });

Doesn't work. The function wont fire on either.

Is this just a slip up or is it for an actual reason?

Cheers,
Will


[jQuery] Re: Look for UL

2009-03-18 Thread ricardobeat

It's not faster, it actually adds a bit of overhead. From jQuery
source code:

// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
return (context || rootjQuery).find( selector );

that means everytime you type $('.someclass', this) it's effectively
being translated to $(this).find('.someclass').

cheers,
- ricardo

On Mar 17, 10:02 pm, Eric Garside gars...@gmail.com wrote:
 As an aside, you can use a different syntax for .find() which last I
 knew was a bit faster and less characters:

 $(this).find('.someclass')

 is equivilent to:

 $('.someclass', $(this))

 On Mar 17, 8:58 pm, so.phis.ti.kat see.marlon@gmail.com wrote:

  Thanks for the tip. I started to use FF's console to see more details
  of the object(s)
  Here's my code:

  $(document).ready(function (){
           $(li.page).click(function (event) {
                    var secondList = ul.categories;
                    if ($(this).find(secondList).length  0) {
                                  
  $(this).children(secondList).slideToggle(slow);
                    }
           });

  });

  On Mar 17, 12:18 pm, mkmanning michaell...@gmail.com wrote:

    if ($(this).find(ul)) { ...

   will always return a jQuery object and so evaluate to true; you need
   to check the length:

    if ($(this).find(ul).length0) { ...

   On Mar 17, 8:57 am, so.phis.ti.kat see.marlon@gmail.com wrote:

Hello Everyone,
I tried doing a search and found some possible solutions but was not
able to get it working for my markup so I am wondering if the
following can be done and how.

Markup
ul class=pages
     li class=page
          a class=current title=Edit index href=# index/a
     /li
     li class=page
          a title=Edit menu href=# menu/a
          ul id=menu class=categories.../ul
     /li
     li class=page
          a title=Edit menu href=# catering/a
          ul id=catering class=categories.../ul
     /li
/ul

So I want to say, when you click on any li class=page/li, look
to see if that li has a child ul... thats it for now. I later want
to use the effects to show and hide the contents of that li.

jQuery
$(document).ready(function (){
         $(li.page).click(function (event) {
                  if ($(this).find(ul)) {
                                alert(yes);
                  } else {
                                alert(no);
                  }
         });

});

Thoughts? Is there a better way or better functions to use?
I tried find and children.


[jQuery] Re: loop through div

2009-03-17 Thread ricardobeat

Oops. Didn't run the code long enough to see that, my mistake. When
this[i] is undefined the jQ object returns with document. Using eq()
instead can fix it.

jQuery.fn.showLoop = function(){
  var i = i || 0, self = this;
   this.eq(i).show(600, function(){
   self.showLoop(++i);
   });
};

but the solution Karl posted should also work and is more concise:

 var $type = $('.type'), i = 0;
 (function(){
 $type.eq(i++).show('normal', arguments.callee);
 })();

cheers,
- ricardo

On Mar 17, 12:30 am, Tom  Shafer tom.sha...@gmail.com wrote:
 doesnt seem to work get a recursion error

 thanks!
 On Mar 16, 7:26 pm, ricardobeat ricardob...@gmail.com wrote:

  jQuery.fn.showLoop = function(i){
    var i = i || 0,
      self = this;
    $( this[i] ).show(600, function(){
         self.showLoop(++i);
    });

  };

  $('.type').showLoop();

  On Mar 16, 7:27 pm, Tom  Shafer tom.sha...@gmail.com wrote:

   how can i loop through each div on a page and have them appear one by
   one
   i am trying

   var arrayList2 = $.makeArray(document.getElementsByClassName
   (.type));

                                                   
   $.each(arrayList2,function() {
                                                           $(this).show();
                                                   });

   thanks

   -tj


[jQuery] Re: Find element. How can I do this?

2009-03-17 Thread ricardobeat

Try this:

var body = fieldset.find('ol:first')

http://docs.jquery.com/Selectors



On Mar 17, 12:13 pm, shapper mdmo...@gmail.com wrote:
 Hello,

 I am trying to find update a plugin to create new functionality.
 On the current version I have the following:

     var legend = fieldset.find(':first');
     var body = jQuery(document.createElement('div'));

 - How can I get the first OL element inside fieldset to use it as body
 instead of creating a new element (the div as it is currently?

 - And can I set which element should be searched (ol, ul, div, etc)
 inside the fieldset?

 Thank you,
 Miguel


[jQuery] Re: $('.edlBoxArea').corners is not a function

2009-03-17 Thread ricardobeat

Are you using jquery.noConflict() in your app?

What do you get on console.log( jQuery.fn.corners )?

On Mar 17, 1:17 pm, boy_named_Goo ssw...@edline.com wrote:
 I'm trying to use the rounded corners plugin -- jquery.corners.js .

 When I create a small test case, below, it works fine.  However, when
 I try to add corners to my production system I receive the following
 error in Firefox's error console:

 $('.edlBoxArea').corners is not a function

 I'm only adding two things to my production system:

 FIRST:

 A reference to the plugin script, in the HEAD section of my html:

 script type=text/javascript src=/jscripts/jquery/
 jquery.corners.js/script

 SECOND:

 In my onload event handler a single Javascript stmt:

 $('.edlBoxArea').corners(10px);

 I've also tried using the following lines of Javascript code in the
 head section instead of an onload event handler.  It gives the same
 error.

 $(document).ready(function(){
     $('.edlBoxArea').corners(10px);

 });

 I've verified via Firebug that the Javascript files are being loaded,
 so it isn't a problem with referencing the external js files.

 I'm using jQuery 1.2.6 and jQuery Corners 0.3.  I've successfully used
 jQuery and other plugins (hoverIntent) successfully.  What could be
 going wrong?

 Here's the simple test case:

 html
 head
 titlecorners/title
 meta http-equiv=Content-Type content=text/html;
 charset=iso-8859-1 /

 script type=text/javascript src=./scripts/jquery.js/script
 script type=text/javascript src=./scripts/jquery.corners.js/
 script

 script language=JavaScript

 function onLoadHandler()
 {
     $('.edlBoxArea').corners(10px);

 }

 /script

 /head

 body onload=onLoadHandler();

 div id=outerDiv

 Maybe there's some text here.br/
 And a little more text here.

 div class=edlBoxArea style=background-color: lightblue;

 This is anbr/
 inner divbr/
 that should have br/
 rounded corners br/
 applied.

 /div

 div class=edlBoxArea style=background-color: tan;

 This is anotherbr/
 inner divbr/
 that should have br/
 rounded corners br/
 applied.

 /div

 /div

 /body
 /html


[jQuery] Re: Change Table Row Color based on column content

2009-03-16 Thread ricardobeat

Assuming you have this:

table id=dj
tbody class=options
  tr
tdSomething here/td
tdinput type=checkbox //td
  tr
/tbody
/table

You'd use this javascript:

$('#dj .options tr').each(function(){
   var self = $(this);
   self.find(':checkbox').click(function(){
   self.toggleClass('selected')
   });
});

I don't know if it's possible for the click event to fire on the
checkbox without it's value changing. If that happens you can use this
instead of toggleClass:

this.checked
  ? self.addClass('selected')
   : self.removeClass('selected');

And this CSS:

#dj .options tr.selected { background-color: #0FC }

cheers,
- ricardo
On Mar 16, 12:25 pm, bsisco blake.si...@gmail.com wrote:
 I have a django app where i have a model which contains a boolean
 (checkbox) field.  What i would like to do is change the corresponding
 table row color in the admin table based on whether or not this field
 is checked.  i have come to the conclusion that this is only possible
 with jquery.  i am a complete n00b when it comes to jquery so i was
 looking for some guidance/suggestions on how i might be able to
 accomplish this.

 Cheers


[jQuery] Re: unbind all events from jquery 1.3.2

2009-03-16 Thread ricardobeat

You could simply use

$(window).trigger('unload')

That will unbind all events bound through jQuery. A function for doing
that is already defined in the source code:

jQuery( window ).bind( 'unload', function(){
for ( var id in jQuery.cache )
// Skip the window
if ( id != 1  jQuery.cache[ id ].handle )
jQuery.event.remove( jQuery.cache[ id ].handle.elem );
});

cheers
- ricardo

On Mar 16, 4:21 pm, Jonathan jdd...@gmail.com wrote:
 jQuerys selector engine is browser independent. So $(*) actually
 refers to all elements and works in all browsers (this is why we love
 it).

 But I would be careful. $(*).unbind() can be slow.

 On Mar 16, 11:50 am, redcom red...@gmail.com wrote:

  isn't this ie specific?

  On Mar 16, 8:50 pm, MorningZ morni...@gmail.com wrote:

   *maybe*

   $(*).unbind();

   all your code is looking at the document itself and then the body
   tag itself

   On Mar 16, 2:44 pm, redcom red...@gmail.com wrote:

Hello
I have a custom application build on top of gecko 1.9 and using
spidermonkey and some c++ calls js-c++-js

When i reload one application page i get some events triggered after
the page has been loaded.
The GC is destroying my objects and html elements some how, but the
events remain attached.

Is there a possibility to unbind all events at once?

I tried: $(window).unload(function () {
$(document).unbind(); or $(body).unbind(); or $(document,
window).unbind();

});

but the events are still somewhere in a cache system.

Can or is there a flag that i can set and prevent jquery to use cache?

The jquery is 1.3.2


[jQuery] Re: Dependant on string does not work

2009-03-16 Thread ricardobeat

Have you tried 1.3.2? A lot of selector bugs have been fixed in this
release.

Try changing it to return !!$(element.form).find(param).length and see
if it works.

- ricardo

On Mar 16, 4:30 pm, chielsen mich...@thalent.nl wrote:
 So i upgraded to the latest version and waisted my day :(
 Seems like the dependant requiring does not work (withh 1.3.1).

 The error occures for instance when you have a require: '#item:filled'
 option.
 What happends is in this code:

                 depend: function(param, element) {
                         return this.dependTypes[typeof param]
                                 ? this.dependTypes[typeof param](param, 
 element)
                                 : true;
                 },

                 dependTypes: {
                         boolean: function(param, element) {
                                 return param;
                         },
                         string: function(param, element) {
                                 return !!$(param, element.form).length;
                         },
                         function: function(param, element) {
                                 return param(element);
                         }
                 },

 The depend function gets called with '#item:filled', and the
 formelement.
 Then the depenTypes['string'] function gets called, with the same
 arguments.

 now $(param, element.form) returns nothing .. This is because a string
 and an element get combined.
 It does work with 2 elements or 2 strings.

 Now the easy fix is to just leave of the 2nd term, element.form. IMO
 you don't really need it anyway


[jQuery] Re: loop through div

2009-03-16 Thread ricardobeat


jQuery.fn.showLoop = function(i){
  var i = i || 0,
self = this;
  $( this[i] ).show(600, function(){
   self.showLoop(++i);
  });
};

$('.type').showLoop();

On Mar 16, 7:27 pm, Tom  Shafer tom.sha...@gmail.com wrote:
 how can i loop through each div on a page and have them appear one by
 one
 i am trying

 var arrayList2 = $.makeArray(document.getElementsByClassName
 (.type));

                                                 $.each(arrayList2,function() {
                                                         $(this).show();
                                                 });

 thanks

 -tj


[jQuery] Re: Flying clouds like in http://devthought.com/

2009-03-14 Thread ricardobeat


http://devthought.com/projects/mootools/apng/

On Mar 14, 12:29 pm, Grom grommas...@gmail.com wrote:
 Hello.
 I want to add flying clouds like onhttp://devthought.com/on my site.
 Do anyone know how to do that? Maybe any suggestions?


[jQuery] Re: wrap some tag around group of table rows for hide and show

2009-03-14 Thread ricardobeat

You can't wrap any element around trs. Tables can only contain a
tbody/thead/tfoot and TRs, if you insert an element that is not
allowed, it itself will be wrapped by a new TR created by the browser,
and you'll get all kinds of misbehavior. You could insert a new tbody,
but browser handling of them is different.

The problem is that the tbodies are being set to display:block after
the show('fast') call. Changing that to fadeIn('fast') seems to work,
I'm not sure why - both should restore the original display.

cheers,
- ricardo

On Mar 14, 1:47 pm, Lwangaman donjohn.f...@gmail.com wrote:
 Ok let's see if this post works... The last couple tries didn't!

 I was reading through this year-old thread which I found googling
 since I'm doing something similar, perhaps someone could give me a
 couple tips.

 Here is the page with the example I'm dealing 
 with:http://johnrdorazio.altervista.org/SitoFlatnukePersonale/index.php?mo...

 Clicking on the checkboxes, two rows should appear (which were hidden
 from the beginning) in which more information can be inserted (that
 otherwise would not be necessary).

 The only problem is, it seems to work only in Internet Explorer. In
 Firefox the rows wind up appearing at the bottom of the table, and
 every time you un-click and re-click some mysterious space begins
 accumulating. Not only, but the cells of the two appearing rows don't
 line up with the cells of all the other rows of the table, the seem to
 want to line up with only the first column which really opens up wide
 that first column shifting the whole table over to the right. Google
 Chrome presents a similar problem, only the appearing rows don't wind
 up at the bottom of the table. They stay where they're supposed to be,
 but the cells still don't line up and they shift the whole table, and
 un-click re-click still creates that mysterious gap.

 At first I was applying JQuery directly to the rows that were
 involved, then reading this thread I tried creating different tbody
 sections and applying the JQuery to those sections, but the problems
 remain. Perhaps it could be a problem of parent-child relationships?
 I'm not sure how those work though, if anyone has any thoughts I would
 be very grateful.

 Here is my code:

 script type=text/javascript src=/SitoFlatnukePersonale/include/
 javascripts/jquery.js/script
 script type=text/javascript

 $(document).ready(function(){

 $(.showhidesection).hide();
 $(#pastoralcounsel).click(function(){
 if ($(#pastoralcounsel:checked).val()!=null)
 {
 $(#represents).show(fast);}

 else
 {
 $(#represents).hide(fast);}
 });

 $(#i_am_a_catechist).click(function(){
 if ($(#i_am_a_catechist:checked).val()!=null)
 {
 $(#catechizes).show(fast);}

 else
 {
 $(#catechizes).hide(fast);}
 });

 $(#volunteer).click(function(){
 if ($(#volunteer:checked).val()!=null)
 {
 $(#volunteers).show(fast);}

 else
 {
 $(#volunteers).hide(fast);

 }
 });
 });

 /script

 table class=sample

 tbody class=alwaysshowsection
 trtdinput type=checkbox name=pastoralcounsel
 id=pastoralcounsel/tdtdlabel for=pastoralcounselCons.
 Pastorale/label/td/tr
 /tbody

 tbody id=represents class=showhidesection
 trtd---/tdtdlabel for=i_represent - rappresenta:/label/
 td/tr
 trtd.../tdtdinput type=text name=i_represent
 id=i_represent/td/tr
 /tbody

 tbody class=alwayshowsection
 trtdinput type=checkbox name=i_am_a_catechist
 id=i_am_a_catechist/tdtdlabel
 for=i_am_a_catechistCatechista/label/td/tr
 /tbody

 tbody id=catechizes class=showhidesection
 trtd---/tdtdlabel for=i_catechize_this_group - del
 gruppo:/label/td/tr
 trtd.../tdtdselect name=i_catechize_this_group
 id=i_catechize_this_groupoptionI^ Anno Comunioni/option/
 select/td/tr
 /tbody

 tbody class=alwaysshowsection
 trtdinput type=checkbox name=volunteer id=volunteer/
 tdtdlabel for=volunteerVolontario parrocchiale/label/td/
 tr
 /tbody

 tbody id=volunteers class=showhidesection
 trtd---/tdtdlabel for=voluntaryservice - servizio:/
 label/td/tr
 trtd.../tdtdinput type=text name=voluntaryservice
 id=voluntaryservice //td/tr
 /tbody

 /table


[jQuery] Re: Flying clouds like in http://devthought.com/

2009-03-14 Thread ricardobeat

That's the code in use on the page you mentioned.

I guess you could do something like that with jQuery's built-in animate
() function:

(function animateMe(){

$('#cloud1')
  .animate({ marginLeft:+=200px }, 2000)
  .animate({ marginLeft:-=200px }, 2000, function(){
 animateMe();
  });
})();


On Mar 14, 3:26 pm, Grom grommas...@gmail.com wrote:
 Its not that. He wrote code to move image using mootools. Im looking
 for something to move image on page for Jquery

 On 14 Mar, 18:44, ricardobeat ricardob...@gmail.com wrote:

 http://devthought.com/projects/mootools/apng/

  On Mar 14, 12:29 pm, Grom grommas...@gmail.com wrote:

   Hello.
   I want to add flying clouds like onhttp://devthought.com/onmysite.
   Do anyone know how to do that? Maybe any suggestions?


[jQuery] Re: test for .is(:visible) fails in Safari

2009-03-14 Thread ricardobeat

Try this:

el.find(#pic)
.attr({src: pix[imgName].imgSrc, name: imgName})
.bind('load readystatechange', function(e){
   if (this.complete || (this.readyState == 'complete'  e.type =
'readystatechange')) {
el.fadeIn(slow);
   $(#loading).hide();
   };
});

The onload event for images is a cross-browser mess.

- ricardo

On Mar 14, 7:27 pm, Jon Crump jjcr...@myuw.net wrote:
 Dear all,

 OK, solved it myself in case anyone's still listening. It still remains a
 puzzle why safari on Mac interprets the code differently.

 The if/else test below isn't necessary. The fadeOut was executing, but the
 .load() callback failed when the .thumb clicked was the same one as the
 previous click. Both FF and IE didn't blink when the src of #pic remained
 the same, but safari wouldn't execute the .load callback because nothing
 loaded: the src of #pic remained the same.

 The solution for my purposes was to set the src of #pic to null and then
 re-set it to pix[imgName].imgSrc whatever it might be, then .load() sees
 that something has loaded and executes the callback.

 Is this a known discrepancy between how FF, IE, and Safari interpret
 .load(), or something completely screwy and idiosyncratic to my klugy
 code? (jQuery 1.2.6, by the way, in safari 3.1.2)

 Jon

 On Fri, 13 Mar 2009, Jon Crump wrote:

  Dear all,

  I'm not sure if this is a jQuery question or not, but I got the following
  code to work in FF, but it fails in Safari:

  $(.thumb).click(function() {
     var imgName = $(this).attr(alt);
     var el = $(#dropdown);
     if (el.is(:visible)  $(#pic).attr(name) == imgName) return;
     else {
         el.fadeOut(slow, function() {
             $(#loading).show();

             el.find(#textContent)
             .text(pix[imgName].aText);

             el.find(#pic)
             .attr({src: pix[imgName].imgSrc, name: imgName})
             .load(function(){
                 el.fadeIn(slow);
                 $(#loading).hide();
             });
         });
     }
  });

  The if/else test was necessitated by the fact that if the user clicked on 
  the
  same thumbnail image twice, the #dropdown element faded out and didn't fade
  back in.

  In FF clicking on the same image twice makes no change, but in Safari,
  clicking on the same image twice makes no change IF #dropdown is visible, if
  #dropdown is NOT visible and the user clicks on the same thumbnail that was
  last clicked on, the loading gif displays but the #dropdown does not.

  I'm sure this is just my own javascript inexperience, but can anyone suggest
  where I'm going wrong?

  Thanks,
  Jon


[jQuery] Re: JQuery Selector

2009-03-13 Thread ricardobeat

It's not a selector. Where did you come across that?

The   makes it think you want to create an element. It does
nothing more than creating a textNode that contains the string %=x.y
% (and a temporary DIV to hold it).

This $(' ') does the same. The '#' is ignored just as if you used $
('#div/') - that simply creates a DIV.

cheers,
- ricardo

On Mar 13, 3:44 pm, rayglaser raymond.gla...@qpaynet.com wrote:
 This form of a selector is undocumented..

 ('#%=x.y%').length

 What does it mean ?

 Thanks..


[jQuery] Re: whats wrong with my custom selector :readonly (IE6 sucks)

2009-03-13 Thread ricardobeat

You're welcome!

'readOnly' is the DOM property, not the attribute - these are (to some
extent) separate things. It's in the HTML4 and DOM Level 1 specs:

http://www.w3.org/TR/2000/WD-DOM-Level-1-2929/level-one-html.html#ID-6043025
http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#adef-readonly

cheers,
- ricardo

On Mar 13, 5:00 am, ggerri gerald.ressm...@ewz.ch wrote:
 Thanks a lot Ricardo :handshake:

 That both worked =)

 But I have to admit that I dont know why .readOnly works.:confused: couldnt
 find anything like that in the docs and thought that you always have to
 select attributes with [..] or .attr(..) Is this an officially working
 function?

 Thanks :-)
 Gerald



 ricardobeat wrote:

  You're returning the object you created, so that will always be true.
  Return the .length property and it shoud work:

  $.extend($.expr[':'],{
      readonly: function(a) {
          return !!$(a).filter('[readonly=true],
  [readonly=]').length;
      }
  });

  But a simpler/faster/safer alternative is the DOM property 'readOnly',
  which seems to work fine on all major browsers:

  $.extend($.expr[':'],{
      readonly: function(a) {
          return !!a.readOnly;
      }
  });

  You have to use !! to enforce returning a boolean value.

  cheers,
  - ricardo
  On Mar 12, 9:30 am, ggerri gerald.ressm...@ewz.ch wrote:
  Hi there
  jQuery 1.3 has problems with handling the readonly attribute (already
  filed
  a ticket but I'm a bit stuck here with my project).  

  When you want to select  readonly inputs, you have to use [readonly=]
  in
  Firefox and [readonly=true] in IE6...

  ( because the DOM looks like that after .attr('readonly','readonly');:
   FF: input id=A1 type=text value=90 readonly=/
   IE6: INPUT id=A1 readOnly=True )

  So I tried to extend :

  $.extend($.expr[':'],{ readonly: function(a) {
                                  return $(a).filter('[readonly=true],
  [readonly=]');
                                                                           
                              }
                                                });

  But:

   $(':text:readonly').addClass('gtest');

  doesnt care about the custom selector and just choses all :text fields.
  :,(

  what's wrong with my extendtion? :confused:

  thanks a lot guys:handshake:
  Gerald

  ps.  $(':text').not([readonly='true'], [readonly=''],
  [readonly='readonly']) works fine in both browsers selecting all input
  fields which are not readonly but using a working :readonly would be more
  elegant right?

  --
  View this message in
  context:http://www.nabble.com/whats-wrong-with-my-custom-selector-%3Areadonly...
  Sent from the jQuery General Discussion mailing list archive at
  Nabble.com.

 --
 View this message in 
 context:http://www.nabble.com/whats-wrong-with-my-custom-selector-%3Areadonly...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Why won't this work in ie ?

2009-03-13 Thread ricardobeat

try this, with the proper closing slash as you're using for img/:

$.each(json, function(i, item){
  $('a/')
 .attr('href', 'http://example.com')
 .html('test')
 .appendTo('#gallery');
});
}

On Mar 12, 4:57 pm, joshm joshmat...@gmail.com wrote:
 In my jquery code I do:
 $.each(json, function(i, item) {
 $('a').attr('href', 'http://example.com').html('test').appendTo
 ('#gallery');

 }

 I have a div to hold the content in the html:
 div id=gallery
 /div

 In firefox I will get  a series of links, in ie7 i get nothing...

 I can replace the code with this and it works fine in ie:

 $.each(json, function(i, item) {
 $('img/').attr('src', item).attr('class', 'thumb').appendTo
 ('#gallery');

 }

 Something about the chaining perhaps?


[jQuery] Re: whats wrong with my custom selector :readonly (IE6 sucks)

2009-03-12 Thread ricardobeat

You're returning the object you created, so that will always be true.
Return the .length property and it shoud work:

$.extend($.expr[':'],{
readonly: function(a) {
return !!$(a).filter('[readonly=true],
[readonly=]').length;
}
});

But a simpler/faster/safer alternative is the DOM property 'readOnly',
which seems to work fine on all major browsers:

$.extend($.expr[':'],{
readonly: function(a) {
return !!a.readOnly;
}
});

You have to use !! to enforce returning a boolean value.

cheers,
- ricardo
On Mar 12, 9:30 am, ggerri gerald.ressm...@ewz.ch wrote:
 Hi there
 jQuery 1.3 has problems with handling the readonly attribute (already filed
 a ticket but I'm a bit stuck here with my project).  

 When you want to select  readonly inputs, you have to use [readonly=] in
 Firefox and [readonly=true] in IE6...

 ( because the DOM looks like that after .attr('readonly','readonly');:
  FF: input id=A1 type=text value=90 readonly=/
  IE6: INPUT id=A1 readOnly=True )

 So I tried to extend :

 $.extend($.expr[':'],{ readonly: function(a) {
                                 return $(a).filter('[readonly=true],
 [readonly=]');
                                                                               
                         }
                                               });

 But:

  $(':text:readonly').addClass('gtest');

 doesnt care about the custom selector and just choses all :text fields. :,(

 what's wrong with my extendtion? :confused:

 thanks a lot guys:handshake:
 Gerald

 ps.  $(':text').not([readonly='true'], [readonly=''],
 [readonly='readonly']) works fine in both browsers selecting all input
 fields which are not readonly but using a working :readonly would be more
 elegant right?

 --
 View this message in 
 context:http://www.nabble.com/whats-wrong-with-my-custom-selector-%3Areadonly...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Switching Content in same div

2009-03-11 Thread ricardobeat

Can't you load both products, each in it's own container, and show/
hide them? That's easier and faster.

div id=products
   div class=red
   /div
   div class=blue style=display:none
   /div
/div

$('#products .blue').show();
$('#products .red').hide();
etc.


On Mar 11, 11:30 am, Desinger p.pad...@gmail.com wrote:
 Hi,

 Product page would like to load different contents in same div
 For example :

 Red product and Blue product

 Default it loads red product and when u click on blueimage product
 image and discription should load in the same div.

 I hope I have conveyd my message clearly


[jQuery] Re: live() not working in IE8?

2009-03-11 Thread ricardobeat

How about

$('#orderlineform #productlisting').load('orderProxy.cfm',
   {
  mode:'getAvailableProducts',
  ordergrade_id:ordergrade_id,
  order_id:order_id
   },
   function(){
  $(this).find('#product_id').change
(isRentalActive);
});

On Mar 11, 11:19 am, Todd Rafferty web...@gmail.com wrote:
 I have a drop down that is being generated via load() - to be 100%
 clear, I'll restate that. The drop down does not exist on the actual
 page.  I'm doing this:

         $('#orderlineform #productlisting').load('orderProxy.cfm',
                 {
                          mode:'getAvailableProducts'
                         ,ordergrade_id:ordergrade_id
                         ,order_id:order_id
                 }
         );

 This is generating the drop down for me and putting it inside the
 #produclisting span for me. Now, just attaching a 'change' event on it
 wasn't working, so I looked into livequery() (eventually live() ) --
 using it works just fine in FireFox, but fails in IE.

 $('#orderlineform #product_id').live('change',isRentalActive);
 -
 function isRentalActive(){
         var data = $(#orderlineform #product_id option:selected).metadata
 ({type:'attr',name:'data'});
         alert(data);
         return false;
         if(data.return_flag == 0){
                 $('.rental').css(display, table-row-group).show();
         }else{
                 $('.rental').hide();
         }

 }

 Any suggestions as to why this is failing in IE?

 Thanks,
 ~Todd


[jQuery] Re: How to prevent third-party CSS code override our CSS

2009-03-11 Thread ricardobeat

Just wrap your re-usable parts in a container with an ID. IDs have
greater weight on CSS rules, that will usually be enough. putting !
important on all your rules will bloat your code unnecessarily.

See this article on CSS specifity:
http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/

On Mar 11, 7:38 am, Nguyễn Quốc Vinh kureik...@gmail.com wrote:
 I'm using sortable of jQuery UI!
 My elements  such as UL tag, LI tag(sortable, dragable,..element) may put
 into many template!
 And each template have thier own CSS, so, that CSS override CSS of my LI tag

 Have anyway to clear all CSS apply on our element, then apply new CSS? Or i
 must use !important for all property to prevent overriding!

 Take a look on two 
 URL:http://trademerchants.com/delnow/kurei/dnd//themes/hr/html/index.myTe...

 http://trademerchants.com/delnow/kurei/dnd//themes/template1/html/ind...

 As you can see, li item appeas in other style because each template have
 own CSS

 Does anyone know how to prevent this?


[jQuery] Re: Dynamically generate file with jquery

2009-03-11 Thread ricardobeat


When javascript/HTML kicks in the headers have already been sent,
there is nothing you can do except offering copy  paste :)

A server-side script that does it for you is not much of a burden, it
could be made very light. I think you could get the text from POST and
stream it directly without the need to save it server-side.

cheers,
- ricardo

On Mar 11, 5:10 pm, Andiih andyhaw...@googlemail.com wrote:
 I'm trying to see if it is possible to convert a table on a page to a
 csv and offer it to the user for download.  Obviously I could grab the
 data and post it to the server for some aspx or php to revert it with
 the correct content type (or even do it all server side in the 1st
 place) but I am trying to figure out if there is a way to generate
 this all client side.  The only bit I need to figure out is if it is
 possible to create a popup with the right headers so the browser
 treats it as a file download.

 I have a nasty suspicion the answer may be no ...

 Thx in advance

 Andrew


[jQuery] Re: How to prevent refreshing jQuery menu and still have SEO friendly links/pages??

2009-03-10 Thread ricardobeat

You can keep a sitemap with the whole structure, but ideally you
shouldn't use AJAX to load whole pages in place of links. Reloading
different pages is not bad.


On Mar 10, 10:20 am, 123gotoandplay wesweatyous...@gmail.com wrote:
 Hi all,

 How do i prevent my jQuery from reloading per page, but still have SEO
 friendly pages???

 any tips, pointers


[jQuery] Re: Does the ready event wait for JavaScript files to be downloaded?

2009-03-10 Thread ricardobeat

If the scripts are not present at page load they will load after ready
has already fired. You'll have to use a callback (like in JSONP) to
fire when a script has loaded. There was a posting recently about a
plugin that loads js in an iframe and uses the body onload event, but
I can't remember it's name.

cheers,
- ricardo

On Mar 10, 4:32 pm, Angus trimk...@sbcglobal.net wrote:
 I am working on a Web app that will consist of virtually empty html
 pages to be downloaded with references in the head tag to JS files
 that will be used to dynamically construct the elements of the page.
 I have read that the ready event waits until the DOM is loaded and
 manipulable.  Would this mean waiting until all of the JS includes
 have been downloaded?

 Thanks.


[jQuery] Re: Undefined function

2009-03-10 Thread ricardobeat

Just a guess: are you defined that function inside $(document).ready
() ? If you are, it's only available inside that scope, you should
define it outside so it's declared globally. But a better approach is,
like mike said, to use proper event binding instead of inline
attributes. It's cleaner and easier to understand.

cheers,
- ricardo

On Mar 10, 6:31 pm, surreal5335 surrea...@hotmail.c
om wrote:
 I have been having trouble trying to define a function. I've tried
 every idea I have come across on the internet but nothing worked. I
 hope some one here has an of how to get it defined properly.

 The code that is not defined is:

 var currentUl = 1;
 function showMe(n) {
         $(ul#gallery).click(function(){
                 $(#+currentUl).hide();
                 $(#+n).show();
                 $(div#picture).show();
                 $(span#picture).show();
                 $(img#space).hide();
         });

 currentUl = n;

 };

 This basic setup has worked for me in the past with just pure
 javascript.

 The html I am using to call it is:

 onclick=showMe('3');

 I am referencing the function with an:

 id=1

 I would appreciate any help you can offer.

 Thanks a lot


[jQuery] Re: Help with selectors and :not()

2009-03-09 Thread ricardobeat

:not(tr[id^=review])

that says: trs which do NOT contain an id that does NOT equal
review. in other words, TRs which DO contain the word review in
it's id.

You want not contains instead: $('#replies tr[id^=r]:not
([id*=review])');

cheers,
- ricardo

On Mar 9, 1:55 am, Yansky forbo...@gmail.com wrote:
 Hi, I'm trying to get all table rows on a page that have an id that starts
 with the letter r, but not any table rows that have id's which contain the
 word review.

 I've tried to use the :not() method, but I don't think I'm using it
 correctly as it doesn't seem to be filtering out table rows that have id's
 which contain the word review.

 My attempt:
 $('#replies tr[id^=r]:not(tr[id^=review])');

 I've figured out how to do it with regular xpath, but I'm not sure how to
 convert that to a jQuery selector statement.

 var mems = document.evaluate( '//tr[contains(@id, r)][ not(contains(@id,
 review) )]' ,document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null
 );

 for (var l = 0; l  mems.snapshotLength; l++){

         console.log(mems.snapshotItem(l));

 }

 --
 View this message in 
 context:http://www.nabble.com/Help-with-selectors-and-%3Anot%28%29-tp22407206...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Call for contributors: A simple, fast and flexible grid/spreadsheet component.

2009-03-09 Thread ricardobeat

Looks great. I like how the editing works.

One thing: why are you using DIVs instead of a table? That's precisely
the only case where tables should be used, to display tabular data.
It's semantically correct and can offer performance improvements, as
table elements have native properties like their index and direct
access to their children.

cheers,
- ricardo

On Mar 8, 9:31 pm, Tin michael.leib...@gmail.com wrote:
 Hey All,

 I've been working on a grid/spreadsheet control prototype during the
 last couple of weeks.  Seeing how there doesn't seem to be a lot of
 other choices for this sort of thing, I had to write my own.  I've put
 the project up on Google Code and am looking for experienced
 developers who can pick this up and turn it into something that
 everybody can use (a jQuery UI grid plugin?).

 The project is hosted athttp://code.google.com/p/slickgrid/.
 Below is a copy of the project home page.

 Looking forward to your feedback!

 Michael Leibman
 michael.leib...@gmail.com
 Principal Engineer
 Daptiv Inc.

 --

 SlickGrid

 What it is

 Quite simply, SlickGrid is a JavaScript grid/spreadsheet component.

 Some highlights:

 Virtual scrolling/rendering (hundreds of thousands of rows)
 Extremely fast rendering speed
 Configurable  customizable
 Full keyboard navigation
 Resizable/reorderable columns
 Custom cell formatters  editors
 Support for editing and creating new rows.
 GlobalEditorLock to manage concurrent edits in cases where multiple
 Views on a page can edit the same data.
 Why?

 This is pretty much a work-in-progress prototype, so I don't feel like
 spending a lot of time documenting it at this stage. I do think it is
 quite promising though, so I'm putting it up for everybody to see and
 play with. In its current form, it satisfies nearly all of the
 requirements for the project I am working on where I am utilizing it
 in an MVC application, so I'm not sure how much time I can afford on
 turning SlickGrid into something that would work for everybody. If you
 are willing to help out - let me know, and I'll add you to the project
 so that you can contribute.

 Examples

 Basic use:http://slickgrid.googlecode.com/svn/trunk/example1-simple.html

 Adding some 
 formatting:http://slickgrid.googlecode.com/svn/trunk/example2-formatters.html

 Turning it into a 
 spreadsheet:http://slickgrid.googlecode.com/svn/trunk/example3-editing.html

 A more comprehensive test 
 page:http://slickgrid.googlecode.com/svn/trunk/grid.html

 Documentation

 See comments at the top 
 ofhttp://slickgrid.googlecode.com/svn/trunk/slick.grid.js.


[jQuery] Re: Adding values from a variable number of select drop downs

2009-03-07 Thread ricardobeat

function weightTotal(){
   var total = 0;
   $('.weight').each(function(){
   total += +$(this).val(); //if it's an empty string + == 0
   });
   $('#grand_total').html( total + % );
}

cheers,
- ricardo

 On Mar 6, 9:58 pm, shallowman nha...@gmail.com wrote:
 Hello all,

 I am trying to add the values from a variable number of select drop
 downs. I have assigned each select element that I want to add a class
 of weight to make searching for them easier. The goal is to have all
 of the numeric values from each select element with the class weight
 added together and displayed in an html element with the id
 grand_total

 My code so far:

 script type=text/javascript src=scripts/jquery-1.3.2.min.js/
 script
 script type=text/javascript

                         function weightTotal()
                         {

                                 var all = $(.weight);
                                 var temp;
                                 var obj = jQuery.each(all, function() {
                                         if(this.value != )
                                         {
                                                 temp = temp + 
 parseInt(this.value);
                                         }
                                 });

                                 
 document.getElementById(grand_total).innerHTML = temp + %;

                         }

 /script

 So far, the only thing displayed in the grand_total element is NaN%

 Can anyone help a jQuery newbie out? Thanks in advance.


[jQuery] Re: filter some elements problem

2009-03-07 Thread ricardobeat

You can satisfy condition 1 and 3 with this:

$('a:not([href*=javascript])[target!=_blank]')

But it's not that easy for nº 2. What is saved on the onclick
attribute is a function, not plain text. You can see the source code
of the function with the .toString() method, so you could do this:

$('a:not([href*=javascript])[target!=_blank]').filter(function(){
 return this.onclick
 ? this.onclick.toString().indexOf(return false)  0
 : true;
});

Or put it all in the filter function to get slightly better
performance:

$('a').filter(function(){
return (
this.href.indexOf(javascript)  0
 this.target != _blank
 (this.onclick ? this.onclick.toString().indexOf(return
false)  0 : true)
   );
});

Note that the '@' for attribute selectors have been deprecated for a
long time and support for it removed in 1.3.2 (it won't work at all).

cheers,
- ricardo
On Mar 7, 6:57 am, rahman...@gmail.com rahman...@gmail.com wrote:
 i want to select a tags that :
    1.it's href dos not contain javascript:
    2.its onclick attribute dos not contain return false
    3. and it's target is not _blank

 i wrote this rules with jQuery like this 2 codes but it's not working
 true, where is my problem ?!

 1.
   $(A :not('a...@onclick*=\return false\]' , a...@href^=\javascript:
 \] , a...@target=\_blank\] ))

 2.
 $(A).not(a...@target='_blank']).not(a...@onclick*='return
 false']).not(a...@href^='javascript:'])

 thanks before


[jQuery] Re: Regular Expression that works everywhere but in jQuery

2009-03-07 Thread ricardobeat

this seems to work:

scrubbed = code.html().replace(/!--[^--]*--/gi,);

The expression you had would eat everything between the first !--
and the last --. There's probably a more elegant way to do it, but
I can't help any further.

cheers,
- ricardo

On Mar 6, 4:10 pm, Adam adamhow...@gmail.com wrote:
 Hey there,

 I'm trying to use JS to clean up the cruft from a Word doc when it's
 being pasted into a WYSYWIG editor.

 Word puts conditional comments like this in the HTML:

 !--[if !mso] style v\:* {behavior:url(#default#VML);} o\:*
 {behavior:url(#default#VML);} w\:* {behavior:url
 (#default#VML);} .shape {behavior:url(#default#VML);} /style !
 [endif]--

 And I'm using this RegEx (I'm no RegEx-pert, but I've successfully
 tested it here (http://www.regular-expressions.info/
 javascriptexample.html), with the Firefox RegEx add-on, etc.):

 //strip out word cruft
 var scrubbed = code.html().replace(/(!--).*(--)/gi,);

 But it's not working at all. See something I'm missing/stupid I did?

 Thanks!
 Adam


[jQuery] Re: New JQuery User, How do I call this function with timed Interval

2009-03-06 Thread ricardobeat

Try

setInterval(function(){ $('#sliderotate').click(); }, 5000);
or
setInterval(EYE.spacegallery.next, 5000) // without the $ and the s

On Mar 6, 11:39 am, Timz66 timothycrom...@hotmail.com wrote:
 I am trying modify Photo gallery and I want it to rotate through the
 images, I currently use
 setInterval(document.getElementById('sliderotate').click(), 5000);
 but of course this does not work in FireFox.

 As much as I an tell the click is bind in a js file here:

  init: function(opt) {
     opt = $.extend({}, EYE.spacegallery.defaults, opt||{});
     return this.each(function(){
      var el = this;
      if ($(el).is('.spacegallery')) {
       $('a href=# id=sliderotate/a')
        .appendTo(this)
        .addClass(opt.loadingClass)
        .bind('click', EYE.spacegallery.next);
       el.spacegalleryCfg = opt;
       el.spacegalleryCfg.images = el.getElementsByTagName
 ('img').length;
       el.spacegalleryCfg.loaded = 0;
       el.spacegalleryCfg.asin = Math.asin(1);
       el.spacegalleryCfg.asins = {};
       el.spacegalleryCfg.tops = {};
       el.spacegalleryCfg.increment = parseInt
 (el.spacegalleryCfg.perspective/el.spacegalleryCfg.images, 10);

 How can I call this
 .bind('click', EYE.spacegallery.next);
  with a timed interval? I tried setInterval($EYE.spacegallery.next,
 5000); but this does not work. Can anyone give me some guidance on
 this or refer me to a tutorial?

 Tim - New Guy


[jQuery] Re: Simple one: difference between varXy.find(':text') and $(varXy).find(':text')

2009-03-05 Thread ricardobeat

It's mostly done to improve performance. If you save the jQuery object
in a var you only need to find the element once (depending on the
selector it's an expensive operation), and then operate on that single
object. I (and other people) like to put a '$' in front of the var
name when it contains a jQ object, to make it clear:

var $mySet = $('.mystuff'); //jQ object
$mySet.click(...).append(...)

var myElement = $('#someelement')[0]; //HTML element
$(myElement).doSomething();

by doing $($mySet) you're unnecessarily creating a new object from the
one you have already stored. It's not really much overhead, but bloats
code.

ggerri: this.something() where 'something' is a jQuery method is
usually found in plug-ins:

jQuery.fn.doSomething = function(){
 // in here, 'this' refers to the current jQuery object/set
 //so you can use methods on it, like each
 this.each(function(){
// here, 'this' is the current element in the loop, not a jq
object
//so you need to wrap it in jQ before using it
$(this).append(...)
 });
};

cheers,
- ricardo

On Mar 5, 9:58 am, Rick Faircloth r...@whitestonemedia.com wrote:
 Hi, Rayn :handshake: :o)

 I think, for shorthand notation (some say for readability, but I think 
 otherwise),
 some set var's (variables) to represent pieces of code, for instance:

 var mySet = '$(mySet)'

 and then use it as:

 mySet.find(':text')...

 Written in longhand, it would be:

 $('mySet').find(':text')...

 When trying to read someone else's code, where this shorthand is use 
 extensively,
 I just find it hard to decipher, since I have to trace all the var's down to 
 find
 out what they stand for...

 Someone please correct me if I'm wrong...

 Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of ggerri
 Sent: Thursday, March 05, 2009 7:31 AM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: Simple one: difference between varXy.find(':text') and 
 $(varXy).find(':text')

 Thanks Ryan :handshake:

 so  mySet.find(':text').each(...) would be right and
 $(mySet).find(':text').each(...) not? :confused:

 In examples I often see (within an each function): $(this).something but also 
 this.something

 Still dont get the difference of use :,(

 G

 ryan.joyce...@googlemail.com wrote:

  mySet is an object or variable, $(mySet) will try to get an element
  using the contents of mySet as the selector.

  On Mar 5, 10:04 am, ggerri gerald.ressm...@ewz.ch wrote:
  Hi there

  thats an easy one for you ;-)

  if i do:

  var mySet = $('trtd:nth-child(2n)');

  how do I use mySet? What's the difference between

  mySet.find(':text')

  and

  $(mySet).find(':text')

  Thanks :-))
  GGerri

  --
  View this message in
  context:http://www.nabble.com/Simple-one%3A-difference-between-varXy.find%28%...
  Sent from the jQuery General Discussion mailing list archive at
  Nabble.com.

 --
 View this message in 
 context:http://www.nabble.com/Simple-one%3A-difference-between-varXy.find%28%...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Need to insert an element in DIV at position X Y

2009-03-05 Thread ricardobeat

Insert anywhere and use position:absolute.

On Mar 5, 8:03 am, choesang tchoes...@gmail.com wrote:
 Hi!

 I am trying to create a webpage where users can insert a pin (div) in
 between the text using context menu.
 My problem is that i do not know how to insert at the exact position.
 Using Dom's I can arrive only to the nearest DIV but a DIV contains a
 lot of text and the PIN has to be position close to the text.

 I can obtain the position of the mouse click using pageX and pageY but
 dont know how to insert an element at that position. I tried
 insertAfter, prepend, append but not getting the desired result.

 Any idea how to solve this problem.

 regards,
 choesang tenzin


[jQuery] Re: Javascript search library

2009-03-05 Thread ricardobeat

Maybe you can use jQuery's filter method:

$(JSONObject).filter(function(){
 return this.cactus = 'green'  !this.water;
});

On Mar 4, 11:00 pm, Khai khaitd...@gmail.com wrote:
 I have a collection of DIVs (or a JSON array).  Is there a javascript
 library that can search through a JSON array and return a collection
 of matched elements, and support advanced search with boolean
 operator?

 Thanks
 Khai


[jQuery] Re: Simple one: difference between varXy.find(':text') and $(varXy).find(':text')

2009-03-05 Thread ricardobeat

For one or two references it will probably be irrelevant, but for
cases where you're looping over with each() it can make a meaningful
difference. A selector like $('div:not(#topo) div.home
div .subdestaque') takes between 5-20ms depending on the browser, by
saving the object in a variable you cut the whole of that time for
each use - a local variable lookup is, for performance matters,
instantaneous.

cheers,
- ricardo

On Mar 5, 1:07 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 Thanks for the further input, Ricardo...

 Is there any way you can put a percentage of processing and/or time saved
 by using var with elements?  Especially if there is only one or two
 references on a page?

 Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of ricardobeat
 Sent: Thursday, March 05, 2009 11:00 AM
 To: jQuery (English)
 Subject: [jQuery] Re: Simple one: difference between varXy.find(':text') and
 $(varXy).find(':text')

 It's mostly done to improve performance. If you save the jQuery object in a
 var you only need to find the element once (depending on the selector it's
 an expensive operation), and then operate on that single object. I (and
 other people) like to put a '$' in front of the var name when it contains a
 jQ object, to make it clear:

 var $mySet = $('.mystuff'); //jQ object
 $mySet.click(...).append(...)

 var myElement = $('#someelement')[0]; //HTML element
 $(myElement).doSomething();

 by doing $($mySet) you're unnecessarily creating a new object from the one
 you have already stored. It's not really much overhead, but bloats code.

 ggerri: this.something() where 'something' is a jQuery method is usually
 found in plug-ins:

 jQuery.fn.doSomething = function(){
      // in here, 'this' refers to the current jQuery object/set
      //so you can use methods on it, like each
      this.each(function(){
         // here, 'this' is the current element in the loop, not a jq object
         //so you need to wrap it in jQ before using it
         $(this).append(...)
      });
 };

 cheers,
 - ricardo

 On Mar 5, 9:58 am, Rick Faircloth r...@whitestonemedia.com wrote:
  Hi, Rayn :handshake: :o)

  I think, for shorthand notation (some say for readability, but I think
  otherwise), some set var's (variables) to represent pieces of code, for
 instance:

  var mySet = '$(mySet)'

  and then use it as:

  mySet.find(':text')...

  Written in longhand, it would be:

  $('mySet').find(':text')...

  When trying to read someone else's code, where this shorthand is use
  extensively, I just find it hard to decipher, since I have to trace
  all the var's down to find out what they stand for...

  Someone please correct me if I'm wrong...

  Rick

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com]
  On Behalf Of ggerri
  Sent: Thursday, March 05, 2009 7:31 AM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: Simple one: difference between
  varXy.find(':text') and $(varXy).find(':text')

  Thanks Ryan :handshake:

  so  mySet.find(':text').each(...) would be right and
  $(mySet).find(':text').each(...) not? :confused:

  In examples I often see (within an each function): $(this).something
  but also this.something

  Still dont get the difference of use :,(

  G

  ryan.joyce...@googlemail.com wrote:

   mySet is an object or variable, $(mySet) will try to get an element
   using the contents of mySet as the selector.

   On Mar 5, 10:04 am, ggerri gerald.ressm...@ewz.ch wrote:
   Hi there

   thats an easy one for you ;-)

   if i do:

   var mySet = $('trtd:nth-child(2n)');

   how do I use mySet? What's the difference between

   mySet.find(':text')

   and

   $(mySet).find(':text')

   Thanks :-))
   GGerri

   --
   View this message in

 context:http://www.nabble.com/Simple-one%3A-difference-between-varXy.find%28
 %...
   Sent from the jQuery General Discussion mailing list archive at
   Nabble.com.

  --
  View this message in
 context:http://www.nabble.com/Simple-one%3A-difference-between-varXy.find%28
 %...
  Sent from the jQuery General Discussion mailing list archive at
 Nabble.com.


[jQuery] Re: .clone a form

2009-03-05 Thread ricardobeat

You can append more than one thing at a time:

$('#clonehere').append($('.hook:first').clone(true), Some textbr /
);

On Mar 5, 3:35 pm, bstoppel brett.telosstud...@gmail.com wrote:
 You're totally right. In my real code I am appending text as well as
 the cloned form.


[jQuery] Re: Get contents of first child tr, td with class

2009-03-05 Thread ricardobeat

You're confusing :first with :first-child. :first-child means the
element must be the first child of it's parent - the tbody never is,
that would be the thead. Also you have the .activity_date class in
your selector but .date in your HTML. From your code this is what
you need to get the content of the first td with class date:

$('#recent_activity td.date:first').text();

cheers,
- ricardo

On Feb 12, 4:26 pm, Mark Steudel msteu...@gmail.com wrote:
 Thanks, though that didn't work for me, though it could be more my
 page doesn't match my example totally. Though I did just come up with
 this, and this seems to work:

 $('.activity_date:first').html() ;

 On Feb 12, 11:21 am, James james.gp@gmail.com wrote:

  $(#recent_activity tbody tr td.date:first).text();

  On Feb 12, 9:13 am, Mark Steudel msteu...@gmail.com wrote:

   I have a table like so:

   table id=recent_activity
   thead
   tr
   tht1/th
   tht2/th
   /tr
   /thead
   tbody
   tr
   tdvalue/td
   td class=date2008-09-01/td --- want this content
   /tr
   tr
   tdvalue/td
   td class=date2008-09-01/td
   /tr
   /tbody
   /table

   And I want to try and get the first td with class date, I've tried the
   following and I get close, but I think I'm just missing something
   easy:

   $('#recent_activity tbody:first-child .activity_date').val(); --
   returns undefined

   or

   $('#recent_activity tbody:first-child .activity_date').html(); --
   returns null

   Thoughts? Better way?

   Thanks


[jQuery] Re: Use iFrame like a normal document

2009-03-05 Thread ricardobeat

You need to use the iframe's document as the context

$('#my_iframe').contents().find('div_im_trying_to_find').offset();
or
$('div_im_trying_to_find', $('#my_iframe')[0].contentDocument).offset
();

I'm curious to know if the dimensions methods will work on it.

- ricardo

On Mar 5, 1:50 pm, cjhill cjh...@gmail.com wrote:
 Hello,

 Unfortunately I have to use an iframe (or unless someone else has a
 better idea). I would like to load a webpage into an iframe and then
 be able to use jQuery to work out where certain divs are located. Note
 that it should base the locations on the iframe and not in relation to
 the whole doument. So, for instance:

 $(div_im_trying_to_find, my_iframe).offset();

 or

 $(iframe div_im_trying_to_find).offset();

 Anyone know if this is possible or whether there is a better, smarter
 way to go about this?
 Thanks.


[jQuery] Re: transition between two classes

2009-03-05 Thread ricardobeat

It's a Wiki, something has broke. I edited it back to the last working
revision temporarily:
http://docs.jquery.com/UI/Effects/ClassTransitions

You should report this at the jquery-UI group for them to fix it
properly.

cheers,
- ricardo

On Mar 5, 6:26 pm, Brian Yanosik byano...@gmail.com wrote:
 Does anyone have any examples of this? I downloaded the UI core which
 supposedly supports this but when I visit the documentation, the page
 is blank.

 http://docs.jquery.com/UI/Effects/ClassTransitions

 Thanks
 Brian


[jQuery] Re: Selecting a child of 'this'

2009-03-04 Thread ricardobeat

You can save a reference to the child elements (if they'll not change)
to avoid finding them over and over:

$(#parent).each(function(){
   var $child = $(this).find('.child');
   var $children = $('.child');

   $(this).hover(function(){
$c.show();
},function(){
$children.hide();
   });

});

On Mar 4, 2:50 am, schickb schi...@gmail.com wrote:
 I'd like to apply a css effect to a child upon hovering over its
 parent. Both are block level elements. The trick is that there is a
 list of these and I only want to modify one at a time. I've got
 something that works, but it feels a bit ugly:

     $(#parent).hover(
         function(){
                 // This is the line in question.
                 $('#' + this.id + ' .child').show();
         },
         function(){
                 // Hide them all
                 $('.child').hide();
         }
     );

 I could use Ids on the children that are derived from their parents,
 but that doesn't seem any cleaner. Is there a better way to handle
 this?


[jQuery] Re: Determine which radio button (if any) is selected on form load.

2009-03-04 Thread ricardobeat

The CF loop doesn't matter, what the HTML output is like? In XHTML the
input element is self-closing (/) and the checked attribute should be
checked=checked.

If nothing else is wrong, both ways work fine: http://jsbin.com/avodi/

On Mar 4, 9:49 am, Swatchdog scott.swatch...@gmail.com wrote:
 Thanks for your attention. I am a new member, so they must be delaying
 me an entire day...

 Just trying to understand this better, so here is where I am on this:

 This works: (It returns the ItemID which is '111')
 $(document).ready(function() {
         console.log($(input[name='ItemID']:checked).val())

 });

 This does not work: (It returns Undefined)
 $(document).ready(function() {
          console.log($('#ItemList input:radio:checked').val())

 });

 Here is the div (with the coldfusion loop)

 div id=ItemList
         cfoutput query=cfqryItemList
                 input type=radio name=ItemID value=#ItemID# cfif 
 FORM.ItemID
 EQ #ItemID# checked/cfif
         /cfoutput
 /div

 It is the only Id=ItemList on the page.

 On Mar 3, 9:01 pm, mkmanning michaell...@gmail.com wrote:

  The problem with an id on the input is there are several inputs, and
  you need to find which one is checked.
  If you're containing div is #itemList then this should work if you
  want the value:

  $('#itemList input:radio:checked').val()

  On Mar 3, 5:37 pm, James james.gp@gmail.com wrote:

   Oops, I forgot the id in the input:
   input type=radio id=ItemList name=myRadio value=blah /

   Oh, and make sure you only have one id=ItemList in your HTML. You
   cannot have several elements with the same id.

   On Mar 3, 3:36 pm, James james.gp@gmail.com wrote:

The code looks fine. Do you have a value defined on your radio input?

Suppose your input is:
input type=radio name=myRadio value=blah /

and your code is:
$(#ItemList:checked).val()  // returns 'blah' if radio is checked
$(#ItemList).is(:checked);  // returns true if radio is checked

On Mar 3, 3:56 am, Swatchdog scott.swatch...@gmail.com wrote:

 I have an order edit form that is fed from Coldfusion/SQL that shows a
 radio list of possible product selections. If the customer is editing
 an order that has already been submitted, one of the products in the
 radio list is selected. If it is a new order, none is selected.

 Upon load, I need to determine which one, if any, is selected so that
 I can turn manipulate other elements on the page.
  The div for the radio input list is id = ItemList.

 This below does not work, it returns Undefined in the alert box.

 $(document).ready(function() {
         alert($(#ItemList:checked).val());

 });

 Can someone throw this jPup a bone?

 Thanks
 SWimmer


[jQuery] Re: next() question

2009-03-04 Thread ricardobeat

:after is used to insert generated content after an element, not to
select the next element. In your code, the :after(...) is doing
nothing, it reads as $('ul.tab-menu a').eq(index + 1) - what's working
is the index.

You don't need to save the index as it's in the scope of the function:

$('#tabs img.albumImage').each(function(index) {
   var $tabs = $('ul.tab-menu a');
   $(this).click(function() {
// in albums, clicking on an image brings the user to the next
image
$( $tabs[index + 1] ).click();
   });
});

The selector you were after is $('li:has(.tab-menu-item-selected) + li
a.tab-menu-item'), but doing the whole parent().next().children('a.tab-
menu-item') stuff is faster, despite being verbose.

cheers,
- ricardo


On Mar 4, 1:01 pm, Joseph Le Brech jlebr...@hotmail.com wrote:
 http://docs.jquery.com/DOM/Traversing/Selectors#Not_supported

 i seen the + operator seems to do something similar, it means an element 
 preceding.

 Date: Wed, 4 Mar 2009 16:54:46 +0100
 Subject: [jQuery] Re: next() question
 From: aplennev...@gmail.com
 To: jquery-en@googlegroups.com

 thanks i got it to work, sort of.

 $('#tabs img.albumImage').each(function(index)
                             {
                                 var $img = $(this).data('tabindex', index);
                                 $img.click(function()
                                 {
                                    // in albums, clicking on an image brings 
 the user to the next image
                                     var index = $(this).data('tabindex');     
                              
                                     $('ul.tab-menu 
 a:after(a.tab-menu-item-selected)').eq(index + 1).trigger('click');
                                 });
                             });

 :after is not documented on the jquery selector 
 page:http://docs.jquery.com/Selectors

 should it be added?

 On Wed, Mar 4, 2009 at 4:21 PM, Joseph Le Brech jlebr...@hotmail.com wrote:

 you should be able to use the :after pseudo element

 http://www.w3.org/TR/CSS2/selector.html#before-and-after

  Date: Wed, 4 Mar 2009 16:10:03 +0100
  Subject: [jQuery] next() question
  From: aplennev...@gmail.com
  To: jquery-en@googlegroups.com

 - Show quoted text -





  Hello,

  say i have this markup:

  ul class=tab-nav-menu tab-menu
  lia class=tab-menu-item tab-menu-item-selected
  href=#fragment00/a/li
  lia class=tab-menu-item href=#fragment11/a/li
  lia class=tab-menu-item href=#fragment22/a/li
  lia class=tab-menu-item href=#fragment33/a/li
  lia class=tab-menu-item href=#fragment44/a/li
   lia class=tab-menu-item href=#fragment55/a/li
  lia class=tab-menu-item href=#fragment66/a/li
  li id=imageLegendArca 180/li

  /ul

  I need to find the anchor link that immediately follows
  a.tab-menu-item-selected. i tried using next but i never get it right

  $('a.tab-menu-item-selected').next('a.tab-menu-item').length returns always   0

  any idea how to find this selector would be greatly appreciated.

  Thanks

  Alexandre

 Windows Live Messenger just got better. Find out more!

 _
  25GB of FREE Online Storage – Find out 
 morehttp://clk.atdmt.com/UKM/go/134665320/direct/01/


[jQuery] Re: How do I translate this in jQuery?

2009-03-04 Thread ricardobeat

Oh, never noticed that funcionality, that's nice. The 'myIframe' var
is unnecessary though.

cheers,
- ricardo

On Mar 3, 3:38 pm, Matt W. propel...@gmail.com wrote:
 function getContentFromIframe(iFrameName) {

    var myIFrame = $(#+iFrameName);

    var content      = myIFrame.contents().find(body).html();

    $('#myiFrame-content').append(content);

 On Mar 3, 9:56 am, Rick Faircloth r...@whitestonemedia.com wrote:

  I've made various attempts at translating this into jQuery without success.

  I guess I'm just not sufficient enough in regular JS to make it work.

  It's working, but I'd like it to be written as much as possible in jQuery
  syntax.

  Would some please translatethe first three lines of this into jQuery for me?

  Thanks,

  Rick

  function getContentFromIframe(iFrameName) {

     var myIFrame = document.getElementById(iFrameName);

     var content      = myIFrame.contentWindow.document.body(innerHTML);

     $('#myiFrame-content').append(content);

  
  --

  My reading of history convinces me that most bad government results from
  too much government.

    - Thomas Jefferson


[jQuery] Re: Objects Methods as event handlers.

2009-03-04 Thread ricardobeat

I wouldn't call it 'corruption'. It's just a different approach. In
jQuery 'this' will always refer to the element to which the method is
being applied. And the data() function doesn't add any properties to
the element.

Any reason to not simply take advantage of scoping?

myClass = function( element ) {
this.element = element;

var obj = this;
this.onclick = function() {
   //this == element
   //obj == this class' instance
}

$(this.element).click( this.onClick );
};

jQuery follows a more functional approach that fits web apps and DOM
handling very well. The closest you'd get to a class in 'traditional'
jQuery is this:

jQuery.fn.myThing = function(){
this.data('something', { some: 'thing', a: 2 })
 .click(function(){
//onclick functions
doSomethingWith( $(this).data('something') );
 });
};

$('#element1,#element2').myThing();

I suggest you take a deep breath and open your mind a bit. The
transition is hard, frameworks are fundamentally different, but that
doesn't make one inherently better or worse than the other.

cheers,
- ricardo

On Mar 4, 6:25 pm, Michael dmgx.mich...@gmail.com wrote:
 And jQuery docs criticize prototype for polluting the global namespace
 and in the same breath recommend binding element properties that would
 normally go on a class to elements with all the potential namespace
 collisions that brings?

 O... K.. (backs away slowly).

 Honestly, the more I use this framework the less I like it.  The
 corruption of 'this' is a major flaw in the framework I don't think
 I'll ever be happy with.

 On Mar 3, 10:32 pm, Dave Methvin dave.meth...@gmail.com wrote:

   one area of functionality has me befuddled
   - using object methods to handle events.

  To continue Karl's point, if you use jQuery the same way you would use
  prototype then you'll be fighting it all the way. The prototype
  solution squirrels away references to the DOM objects in the class and
  then points event handlers back to the class. jQuery usually
  encapsulates the data and events within the DOM element or a closure,
  e.g.:

  $(selector)
    .data(options, {answer: 42})
    .click(function(){
       alert($(this).data(options).answer)
    });


[jQuery] Re: checkbox array

2009-03-03 Thread ricardobeat

http://www.w3.org/TR/html401/interact/forms.html#adef-name-FORM

This is still in use because it's the easiest/fastest way of getting
an array with the selected options server-side. There is no simpler
alternative.

- ricardo

On Mar 3, 12:53 am, mkmanning michaell...@gmail.com wrote:
 That argument's been raging for a while :)

 There appear to be two halves, those that say 'CDATA', so any text is
 OK, and those that read the next part of the spec For some HTML 4
 attributes with CDATA attribute values, the specification imposes
 further constraints on the set of legal values for the attribute that
 may not be expressed by the DTD which is followed by id/name token
 restrictions, which I'll grant is poorly structured and open to
 debate.

 And then there's the third half that just says 'browsers allow it so
 who cares' :P

 rant
 CDATA means characters from the document character set, which includes
 tabs, spaces, character entities like copyright, ampersand, etc.; I
 suspect most people would probably be uncomfortable including them in
 an input's name attribute though.

 My main gripe with this still stands, and I'll try to articulate it
 better:

 I work primarily clientside, mostly writing JavaScript; I started as a
 designer, then went on to HTML and CSS, then to working on the server-
 side. I've written server-side code in Perl, Java, C# and Python, I
 work with different frameworks as a freelancer, very often RoR.
 (Fulltime I'm currently writing js in a .NET shop, although I have a
 niche position of building specialty apps in Python on appengine along
 with UI work).

 When I write a standards compliant, semantic XHTML page, I can drop it
 into a webapp in Python, post a form to the server and process the
 results, with no problems at all. I can take that exact same XHTML
 file and drop it in a webapp in a Java Servlet container and have it
 behave exactly the same, posting and processing on the server, with NO
 CHANGES to the markup.

 My contention is that (most) people aren't using attribute names on
 their inputs like name=foo[] because they like to; it is being
 imposed on them by the server-side framework they've chosen. Thus I
 stand by my original statement that ANY server side framework (and
 that includes frameworks developed for the languages I mentioned
 above), is deficient if it 'requires' the markup be structured a
 specific way.

 I've personally experienced developers using [] in a name, and then
 trying to access it with JavaScript, only to get tripped up by the
 fact that [] has a direct meaning in JavaScript; why make life harder
 if you don't have to?

 /rant

 I don't think this debate is going to end unless some new information
 comes to light, but in deference to keeping the topic of these posts
 to jQuery, I will promise to not bring this up again (nobody's giving
 me any nickels anyway).

 On Mar 2, 7:03 pm, Matt Kruse m...@thekrusefamily.com wrote:

  On Mar 2, 6:51 pm, mkmanning michaell...@gmail.com wrote:

   HTML 4 spec section 6.2 says, ID and NAME tokens must begin with a
   letter ([A-Za-z]) and may be followed by any number of letters,
   digits ([0-9]), hyphens (-), underscores (_), colons (:), and
   periods (.).

  The NAME attribute is CDATA, not ID or NAME.

 http://lmgtfy.com/?q=name+attribute+cdata+id+token
  ;)

  Matt Kruse


[jQuery] Re: Apply class to range of child elements

2009-03-03 Thread ricardobeat

modulus in JS returns the remainder of the division - whatever is left
that couldn't be divided returning an integer.

1/4 = 0.25  -   1%4 = 1
2/4 = 0.5-   2%4 = 2
3/4 == 0.75  -   3%4 == 3
4/4 == 1   -   4%4 == 0
5/4 == 1.25  -   5%4 == 1
6/4 == 1.5-   6%4 == 2
and so on...

By using the modulus on the index you'll get an infinite sequence of
0,1,2,3 for example, which allows us to achieve the separation you
wanted.

This for example would recursively add one of four classes for every
element:
$('a').each(function(i){
   var n = i % 4;
   $(this).addClass(
  n == 0 ? 'first' :
  n == 1 ? 'second' :
  n == 2 ? 'third' :
  n == 3 ? 'fourth' : '');
});

we just add
   var n = Math.floor(i/10) % 4;
because you want four different classes for every 10 elements. We
divide the index by 10, giving us 0.xx to 1 instead of 0 to 10, round
that down and apply the modulus to see which class suits.

As a last simple example, %2 can tell you which numbers are odd or
even:
1%2 == 1
2%2 == 0
3%2 == 1
4%2 == 0
377%2 == 1
5666%2 == 0

Hope this is not too confusing!

cheers,
- ricardo

On Mar 3, 12:21 am, Nic Hubbard nnhubb...@gmail.com wrote:
 Hi Ricardo,

 Could you explain why you did %4 for the n variable?

 On Feb 26, 12:16 pm, ricardobeat ricardob...@gmail.com wrote:

  I like it cleaner:

  $('a').each(function(i){
     var n = Math.floor(i/10) % 4;
     $(this).addClass(
        n == 0 ? 'first' :
        n == 1 ? 'second' :
        n == 2 ? 'third' :
        n == 3 ? 'fourth' : '');

  });

  or

  var classNames = ['first', 'second', 'third', 'fourth'];
  $('a').each(function(i){
     var n = Math.floor(i/10) % 4;
     $(this).addClass(classNames[n]);

  });

  This also gives you support for infinite expansion. An index of 45
  will evaluate to class 'first', 51 to 'second', 85 to 'first' again
  and so on.

  cheers,
  - ricardo

  On Feb 26, 6:29 am, mkmanning michaell...@gmail.com wrote:

   And just as an exercise, here's the 'jQuery' way chained:

   $('a').filter(':lt(10)').addClass('first').end().filter(':gt(9):lt
   (10)').addClass('second').end().filter(':gt(19):lt(10)').addClass
   ('third').end().filter(':gt(29)').addClass('fourth');

   Not really any speed gain though.

   On Feb 26, 1:21 am, mkmanning michaell...@gmail.com wrote:

It's possible. Here's a more traditional way:

        $('a').each(function(i,link){
            if(i10){$(link).addClass('first');}
            else if (i9  i20){$(link).addClass('second');}
            else if (i19i30){$(link).addClass('third');}
                else if (i29i40){$(link).addClass('fourth');}
        })

Here's a more 'jQuery' way:
        $('a:lt(10)').addClass('first');
        $('a:gt(9):lt(10)').addClass('second');
        $('a:gt(19):lt(10)').addClass('third');
        $('a:gt(29):lt(10)').addClass('fourth');

Which is better? The first takes a little over half as long as the
second.

On Feb 25, 10:45 pm, Nic Hubbard nnhubb...@gmail.com wrote:

 I have a list of links, around 40 of them.  I want to apply classes to
 groups of them.  So, items 1-10 I want to apply a class to, then
 11-20, then 21-30 and 31-40, each of these groups should have their
 own class.

 Is something like this possible?  I looked through the jQuery
 selectors and could not find a solution.


[jQuery] Re: Reordering rows using JQuery

2009-03-03 Thread ricardobeat

As other's have said, you should do this server-side. Anyway, here's a
way to do it:

var csv = 'Row2,Row1,Row3',
mytable = $('#mytable')[0]; //save the table for later
csv = csv.split(','); //csv is now an array

var ln = csv.length;
while(ln--){ //loop csv array in reverse
   $('#'+csv[ln]) //build the id string #rowX
  .prependTo(mytable);
}

table id=mytable
tr id=Row1
  tdSome label 1 /td
  tdSome complex control/td
/tr
tr id=Row2
  tdSome label 2/td
  tdSome complex control/td
/tr
tr id=Row3
  tdSome label 3/td
  tdSome complex control/td
/tr
/table

cheers,
- ricardo

On Mar 3, 3:54 pm, spdude sandeshm...@gmail.com wrote:
 anyone?

 On Mar 3, 8:51 am, spdude sandeshm...@gmail.com wrote:

  I dont want to sort the table. Rather, I want to reorder the tr
  based on a csv of the tr ids. This csv can be from the db, viewstate
  or session.

  I would rather not add the controls dynamically to the table as the
  rows have a lot of complicated custom controls and adding them
  dynamically may open up other issues with viewstate etc.

  On Mar 3, 7:02 am, Rasit OZDAS rasitoz...@gmail.com wrote:

   If I understand your problem correctly, you don't need JQuery for this,
   you can just create rows dynamically on start.

   JQuery is needed only when you need to change sorting in the middle, using
   Ajax etc.
   Tablesorter doesn't sort as you want, it sorts like ORDER BY query in 
   SQL.

   I recommend using Jquery Sortable (in JQuery-UI).

   Rasit

   2009/3/3 spdude sandeshm...@gmail.com

I have an aspx page that looks something like this:

tr id=Row1
 tdSome label/td
 tdSome complex control/td
/tr
tr id=Row2
 tdSome label/td
 tdSome complex control/td
/tr
tr id=Row3
 tdSome label/td
 tdSome complex control/td
/tr

As soon as the page is loaded, I would want to reorder these rows
based on the user's previously selected order (stored in a database)

How would I use JQuery/JS to accomplish this?

   --
   M. Raşit ÖZDAŞ


[jQuery] Re: How do I translate this in jQuery?

2009-03-03 Thread ricardobeat

There's not much you can convert to jQuery. It's all javascript
anyway:

function getContentFromIframe(iFrameName) {

  var content = $('body', $('#'+iFrameName)[0].contentDocument).html
();
   $('#myiFrame-content').append(content);

}

- ricardo

On Mar 3, 2:56 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 I've made various attempts at translating this into jQuery without success.

 I guess I'm just not sufficient enough in regular JS to make it work.

 It's working, but I'd like it to be written as much as possible in jQuery
 syntax.

 Would some please translatethe first three lines of this into jQuery for me?

 Thanks,

 Rick

 function getContentFromIframe(iFrameName) {

    var myIFrame = document.getElementById(iFrameName);

    var content      = myIFrame.contentWindow.document.body(innerHTML);

    $('#myiFrame-content').append(content);

 
 --

 My reading of history convinces me that most bad government results from
 too much government.

   - Thomas Jefferson


[jQuery] Re: toggle a checkbox???

2009-03-03 Thread ricardobeat

The best you can do is rewrite it to a simple ternary conditional and
use the .checked property direclty:

$(input[name^=REQ_ACCT_LAB_]).click(function() {
   $(input[name=MY_CHK]).attr('checked', this.checked ?
'checked' : '');
});

cheers,
- ricardo

On Mar 3, 4:15 pm, Jael jae...@yahoo.com wrote:
 thanks for the reply!

 in fact thats exactly what i'm doing but accidentally omitted that event in
 my post.

 So the if statement is as good as it gets?  is there a better jquery (more
 efficient) way of doing this?



 James-279 wrote:

  What you did looks fine if it only runs one on page load. Which means
  if you check/uncheck after the fact, nothing else will happen.
  If you want it to work dynamically, you have to attach an event to the
  checkbox. Maybe something like:

  $(input[name^=REQ_ACCT_LAB_]).click(function() {
              if ($(this).is(:checked))
              {
                  $(input[name=MY_CHK]).attr(checked,checked);
              }
              else
              {
                  $(input[name=MY_CHK]).attr(checked,);
              }
  });

  On Mar 2, 11:36 am, Jael jae...@yahoo.com wrote:
  Hi all,

  I am new to this forum and hope someone can direct me a little..

  I have a checkbox that needs to be checked/unchecked under the following
  rules..

  if any checkboxes with id like REQ_ACCT_LAB_ are checked, then check it
  if all of the checkboxes with id like REQ_ACCT_LAB_ are unchecked, then
  uncheck it.

  Is there a better way of doing this?

  heres my code:

              if ($(input[name^=REQ_ACCT_LAB_]).is(:checked))
              {
                  $(input[name=MY_CHK]).attr(checked,checked);
              }
              else
              {
                  $(input[name=MY_CHK]).attr(checked,);
              }

  Thanks!
  --
  View this message in
  context:http://www.nabble.com/toggle-a-checkboxtp22233470s27240p22233470
  Sent from the jQuery General Discussion mailing list archive at
  Nabble.com.

 --
 View this message in 
 context:http://www.nabble.com/toggle-a-checkboxtp22233470s27240p22315606
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: converting HTML to XML using jQuery

2009-03-03 Thread ricardobeat

Not showing your js function doesn't help much.

All .group are descendants of .map, it's not about context.

Maybe you want this (rough):

$('.map').each(function(){
var xml = 'map';
$(this).find(' .group').each(function(){
   xml += 'group';
   $(this).find(' .group').each(function(){
  xml += 'group';
  xml += $(this).text();
  xml += '/group';
   });
   xml += '/group';
});
xml+= '/map';
});

On Mar 3, 5:27 pm, DReed danreed...@gmail.com wrote:
 I have been struggling with trying to do the following... perhaps I am
 looking at it too hard since I have a feeling the solution is right
 in front of me (i hope).

 I have something like the following:

 div class=map
    div class=titleTitle/div
    div class=group
        Group Name 1
        div class=groupGroup Name 1-1/div
    /div
    div class=group
        Group Name 2
        div class=groupGroup Name 2-1/div
    /div
 /div

 I would like to turn this into XML, like:

 map
    titleTitle/title
    groupGroup Name 1
       groupGroup Name 1-1/group
    /group
    groupGroup Name 2
       groupGroup Name 2-1/group
    /group
 /map

 I have been trying using the .each() function but it doesn't seem to
 hold the context node (when my context is the .map node and I want to
 iterate the .group, it will iterate ALL of them, instead of the TWO
 directly under the .map element.  I can brute force this with some
 recursion but I thought there must be a way to retain the context of
 the jQuery.

 Perhaps the .each way isn't the right approach?

 Thanks in advance.


[jQuery] Re: jQuery.ajaxSetup({ success: ... }) behavior

2009-03-02 Thread ricardobeat

That's correct, ajaxSetup only sets the defaults for every ajax call.
Use ajaxSuccess instead:

$().ajaxSuccess(function(){
   //...
});

http://docs.jquery.com/Ajax/ajaxSuccess#callback

cheers,
- ricardo

On Mar 2, 12:08 pm, creemorian creemor...@gmail.com wrote:
 You're right, this what I'm doing ... I'm afraid I had some
 grammatical errors in my previous u'post.

 I'm sending an appropriate response from the server but what I'm
 trying to do is check for this response on a global basis using the
 $.ajaxSetup() function.

 Unfortunately the ajaxSetup's success() method doesn't execute if the
 local $.post() function has the success() method defined within.

 So it appears that $.ajaxSetup's success method is a fallback; used
 only when not otherwise defined. My expectation was that they would
 both execute ...

 Is there a way to define my desired actions without having to place
 the function in every callback function?

 Thanks and cheers!

 On Feb 27, 8:15 pm, James james.gp@gmail.com wrote:

  Since the session check is done server-side, you can do it with 
  everyAJAXrequest server-side. If their session is not active anymore,
  return a specific status for it. It's good to use JSON response for
  this so you can return several sets of data, such as statuses, data,
  etc.

  On Feb 27, 12:45 pm, creemorian creemor...@gmail.com wrote:

   Along with everyAJAXcallback, I'd like to ensure that the user
   session is still active.

   So I have the following:

 jQuery.ajaxSetup({
   success: function(data, text)
   {
     if ( data.event == login ) {
       window.location.reload();
     }
   }
 });

   The aforementioned code functions perfectly well if theAJAXrequest
   object does *not* have the `({success: ... })` method defined
   locally...

   Is there any way to make theglobalmethod always? Or a better way to
   respond to an expired user session viaAJAX?

   Cheers for any suggestions.


[jQuery] Re: Is jquery suitable for this...

2009-03-02 Thread ricardobeat

That's possible, but you'll have to take care of passing the right
context everytime:

//main page
script type=text/javascript src=jquery.js/script

//inside the iframe
script
$ = jQuery = $('iframe')[0].parent.jQuery;
$('#myElement', document); //pass the iframe's document as context
/script

to exemplify, if you were to do this from the outside:

//main page
var iframe = $('iframe')[0];
iframe.contentWindow.$ = iframe.contentWindow.jQuery = jQuery;
iframe.contentWindow.$('.iframe_element', iframe.contentDocument);
//jquery will search in the context of the document it was loaded in,
if you don't specify one

the practical way to do that would be to save the iframe's document in
an object and always start from there:

var $iframe = $( $('iframe')[0].contentDocument );
$iframe.find('#iframe_element');
$iframe.find('.another_element');

There are probably other caveats for this use of jQuery, it depends on
the complexity of what you're doing.

cheers,
- ricardo

On Mar 2, 5:42 pm, jojobar skdu...@gmail.com wrote:
 Hi!

 I am exploring different options to write a new program and would like
 to get some ideas from the group is this way of doing things makes
 sense...

 I have a main page and an iframe inside that page. We want to keep the
 iframe code very small (because this is a ssl page and javascript wont
 cache), so my idea is to load the jquery_ver.js on the main page but
 use all jquery functions from inside the pages in the iframe.

 This is because the top page will be loaded only once (with menus
 etc.) and will not have impact on performance with lots of
 javascripts.

 Is this possible. I am still learning jquery and tried a few things
 but it won't work.

 Thanks
 jb


[jQuery] Re: Change CSS depending on page you're on

2009-03-01 Thread ricardobeat

Yes we are! You're not only talking about the low percentage of
browsers with JS off, but more important mobile browsers which don't
have full support for javascript. That's a big market.

Besides that, using pure CSS is faster, simpler, less prone to errors
and follows the unobtrusive principles.

cheers,
- ricardo

On Mar 2, 3:38 am, expresso dschin...@gmail.com wrote:
 Another thing I don't get is why everyone says JavaScript is not ideal.  I
 mean are we all really still worrying about users not having JS turned on in
 the year 2009 when almost half the sites or more have JS reliant controls
 and functions on the page?



 expresso wrote:

  Thanks much for clarifying..!

  mkmanning wrote:

  Since it's not a regex, it doesn't matter for the substring if
  it's .asp or .aspx (or .as or .a for that matter). Any of those will
  do.

  On Mar 1, 10:17 pm, expresso dschin...@gmail.com wrote:
  I see now.  Yea, strip out the .aspx (asp is classic, nobody uses that
  anymore)

  then take the page name and set the css to whatever element that has
  that ID
  as the page name's CSS.

  thought about that, and to me that's the best way to to it if going the
  javaScript route.  thanks a lot!

  mkmanning wrote:

   When a user clicks a hyperlink, a new page loads and the code example
   I gave executes -- on the new page ondomready. It never executed on
   the click. That's why it's extracting the pathname from the location
   object.

   On Mar 1, 10:05 pm, expresso dschin...@gmail.com wrote:
   I'm saying this:

   1) User clicks a hyperlink, it calls that javascript method which
  sets
   some
   css class
   2) user is redirected to whatever page that hyperlink represented
   3) you just lost the css that you changed when the user clicked the
   hyperlink

   mkmanning wrote:

I'm not sure what you mean by losing the CSS value? If you load a
  new
page, the CSS loads (preferably in an external stylesheet), and the
JavaScript executes ondomready (the JavaScript would have to be on
every page, or preferably included in an external file also). From
your example markup, each page has it's own unique pathname, so why
would you 'send' something in the querystring as opposed to the
suggested solution?

By 'subtext' I assume you mean subnavigation; that can be handled
  the
same way.

On Mar 1, 8:17 pm, expresso dschin...@gmail.com wrote:
Problem with the JavaScript is that you loose the css value after
   you're
redirected to whatever page.  You'd have to obviously have to
  either
   do
some
if statements to check which .aspx page y ou went to or send the
  id of
the
anchor over in a querystring then grab it in JavaScript to set it
   again
once
you get to that page or else you loose the css that you set due to
redirect
oviously.

mkmanning wrote:

 You can do still do it with asp:

  http://stackoverflow.com/questions/188124/programmatic-solution-to-ch...

 Or if you really want to use JavasScript, the same solution
  above
 applies:

 var pathname = window.location.pathname;
 pathname = pathname.substring(pathname.lastIndexOf('/')
 +1,pathname.indexOf('.asp'))
 $('body').addClass(pathname);

 On Mar 1, 5:47 pm, expresso dschin...@gmail.com wrote:
 But I'm using a asp.net master page and inheriting it's body.
   so
   my
 pages
 only will have one global body tag.

 mkmanning wrote:

  Unless your only option is to resort to JavaScript, this is
something
  you could do with CSS alone, if you put an id or class on the
   body
tag
  for each page and just rely on the CSS hierarchy to change
  the
   style
  for each list item. It also has the advantage of working
immediately,
  instead of waiting for domready for example, and even works
  when
  script is disabled, and can reduce code complexity.

  CSS:
  body.home ul li.home,
  body.about ul li.about,
  body.contact ul li.contact {
     color:red;
  }

  HTML:

  body class=about

  div id=menu
          ul
                li class=home default.aspx home /li
                li class=about about.aspx about /li
               li class=contact contact.aspx contact /li
          /ul
  /div

  On Mar 1, 4:53 pm, expresso dschin...@gmail.com wrote:
  I'm trying to do something simple but this is my first stab
  at
doing
 this
  in
  JQuery.

              div id=menu
                      ul
                              li class=current_page_item
 default.aspx
  home /li
                              li about.aspx about /li
                              li contact.aspx contact /li
                      /ul
              /div

  based on the page, change the css.  So like doing a
   window.location
 and
  then
  parse out the url to the page then check.  If it's the

[jQuery] Re: Newbie needs Help with jquery logic

2009-03-01 Thread ricardobeat

Not sure what this is an answer too (appear as a new subject), but:

$(img:not(this))

You have 'this' as a string in there. That's saying give me all
images which are not a 'this' element. Should be this:

$(img).not(this) //passing the actual DOM element to not()

I prefer to code it this way:

$(function(){
  $('img').bind('click',function(){
 if ( $(this).css('opacity')  1 )
  $(this)
   .stop().fadeTo('slow',1)
   .siblings('img').stop().fadeTo('slow',0.3);
 });
});

The stop() avoids queuing of animations and makes it more responsive.

cheers,
- ricardo

On Mar 2, 1:37 am, Sean O seanodot...@yahoo.com wrote:
 This was a fun one to play with.
 I think this is the effect you're after...

 Demo:http://jsbin.com/iwile
 Source:http://jsbin.com/iwile/edit

 It's pretty concise  self-explanatory, but if you have any questions, just
 reply.

 SEAN Ohttp://www.sean-o.comhttp://twitter.com/seanodotcom



 ixxalnxxi wrote:

  I'm trying to set up a gallery on my own (similar to galleria) so I can
  get my hands dirty with jquery.

  I have a set of images that either have the class inactive or active
  attached to them. When I leave all my images with the inactive class by
  default, everything works fine but it looks terrible because the image div
  is empty and all thumbnails have .33 opacity.

  Now, when I set an image to active, it correctly shows up with an 100
  opacity thumbnail and a filled in image div once i click on another
  thumbnail then move back to the thumbnail that was once by default active,
  it doesn't function correct.

  html,

     td
                      images/01_nintendoDSa.gif
     /td

     td
                      images/02_nintendoDSb.gif
     /td

     td
                      images/03_colourkeys.gif
     /td

  Then the jquery is as follows,

             $(img.inactive).click(function()
             {
                     var image = $(img.active);
                     if(image != $(this))
                     {
                             image.removeClass(active);
                             image.addClass(inactive);
                             image.fadeTo(slow, 0.33);
                             $(this).removeClass(inactive);
                             $(this).addClass(active);
                             $(this).fadeTo(slow, 100);
                     }
             });

  Any suggestions?

 --
 View this message in 
 context:http://www.nabble.com/Newbie-needs-Help-with-jquery-logic-tp22257353s...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: alternate color row starting from a point

2009-02-28 Thread ricardobeat

Two other ways:

$('tr.className + tr').each(function(){
   var nxt = $(this), i=0;
   while (nxt.length){
 nxt.css('backgroundColor', i%2 ? 'white' : 'red');
 nxt = n.next(':not(.className)');
 i++;
   }
});

Or this (I prefer the first, this one is probably slower):

$('tr.className + tr').each(function(){
   var t = $(this), nxt = t;
   while (nxt.length){
 nxt = nxt.next(':not(.className)');
 t = t.add(next);
   }
   t.filter(':even').css('color','red');
   t.filter(:odd').css('color', 'white');
});

cheers,
- ricardo

On Feb 28, 12:06 am, Josh Powell seas...@gmail.com wrote:
 hmmm, tough one, it was fun.

 $(function() {
     var color = '';
     $('#everyother tr').each(function() {
         if( $(this).hasClass('className') ) {
             color = 'red';
         } else if (color === 'red') {
             $(this).css({'background-color': 'red'});
             color = '';
         } else {
             color = 'red';
         }
     });

     table id=everyother
 tr class=classNametdclassName/td/tr
 trtd1/td/tr
 trtd1/td/tr
 tr class=className/tdclassName/td/tr
 trtd1/td/tr
 trtd1/td/tr
 trtd1/td/tr
 tr class=classNametdclassName/td/tr
 trtd1/td/tr
 trtd1/td/tr
 /table

 On Feb 27, 9:03 am, Magritte marco.oliva...@gmail.com wrote:

  Ok, it work, but I another trouble.

  the code now become:
  $('tr:not(.className):odd').css({'background':'red'});

  because I would like to color row alternatively.
  The problem is that I would like that the alternativy start alway with
  red.(first 'tr' after every 'tr class=className//tr' red,
  then 'white', then red,)

  With this code it doesn't happen.

  Thanks

  On 27 Feb, 13:17, Thomas Jaggi thomas.ja...@gmail.com wrote:

   This should do it:
   $('tr:not(.className)').css({'background':'red'});


[jQuery] Re: Waiting for 'each' to finish

2009-02-27 Thread ricardobeat

That's because the animations don't wait. Add the css() to the last
element's animation callback

function nexthour(object, start, stop) {
 var $guide = $(#guide),
  $divs = $('div.bla'),
  ln = divs.length;
 $guide.css('height', $guide.height());
 $divs.each(function(index) {
 $(this).fadeOut(1000, function() {
   $(this).remove();
   var showid = $(this).attr('id');
   showid = showid.replace('guide', );
   startchan(showid, start, stop, 'lame');
 });
if (index==ln) $guide.css('height','auto'); //fire only for the
last element
 });
return false;
}

On Feb 27, 9:54 am, Terpz psy...@sygko.net wrote:
 Hi

 First, the code:http://pastebin.com/m142fb6a4

 The $(#guide).css('height', 'auto'); runs when i run the function,
 and after it changes to auto, it runs the each.
 So, how can i be sure that it has run the each, before it runs
 something else in my function?

 // Martin


[jQuery] Re: Problem in selectors

2009-02-27 Thread ricardobeat

It's hard to tell without seeing the HTML code.

Works fine here: http://jquery.nodnod.net/cases/196

- ricardo

On Feb 27, 2:02 pm, RandyJohnson ra...@srpropertiesllc.net wrote:
 Davide...

 Did you ever get a response.

 I am having a similar problem with 1.3.2 in that I have multiple area
 html statements and only one is being returned when I issue the
 following jquery statement:  $('area').hover
 (popUpDisplay,popUpRemove)...

 Does anybody know what changed between 1.2.6 and 1.3.2.

 This code worked fine in 1.2.6.

 Thanks in advance...

 Randy


[jQuery] Re: $.post error on response

2009-02-27 Thread ricardobeat

Where are you expecting to collect the response? Are you using a
callback?

function check_out_image(image_id) {
   $.post('ajax/checkout_image', {imageid: image_id}, function(resp){
 alert(resp);
  });
}

On Feb 27, 2:41 pm, Dan tribaldr...@gmail.com wrote:
 I'm using jquery 1.3.2 and trying to send some data using $.post to a
 PHP script. For some reason the response is not being returned and
 Firebug is reporting an error on line 3633 of jquery.

 function check_out_image(image_id) {
    $.post('ajax/checkout_image', {imageid: image_id} );

 }

 A very simply function that POST's an image ID to my PHP script. The
 PHP script is getting run and updating a MySQL database so I know it's
 calling the right function and working but the echo response never
 makes it back.

 For reference line 3633 of jquery 1.3.2 is the xhr.send(s.data) line
 below:

         try {
                 xhr.send(s.data);
         } catch(e) {
                 jQuery.handleError(s, xhr, null, e);
         }

 For testing purposes I changed my PHP function to a simple echo foo
 statement with nothing else in it and it still doesn't get returned.
 Any ideas on why the response wouldn't get sent back?

 Thanks,
 Dan


[jQuery] Re: Please, help me convert this flash menu into a jQuery menu?

2009-02-27 Thread ricardobeat

You can do that with pure CSS:

http://jsbin.com/eyivu
http://jsbin.com/eyivu/edit

with jQuery:

$('#menu li a').hover(function(){
   $(this).stop()
  .css({ backgroundColor: '#C66' })
  .animate({ marginLeft: '+=5px' }, 200);
}, function(){
  $(this).stop()
  .css({ backgroundColor: '#ACA' })
  .animate({ marginLeft: '-=5px' }, 200);
});

That's kind of self-explanatory, you'll find all about the working
details at docs.jquery.com

cheers,
- ricardo


On Feb 27, 3:37 pm, 123gotoandplay wesweatyous...@gmail.com wrote:
 Hi there,

 Could anyone get me started to convert this flash menu to a jquery
 menu?www.bldd.nl/jsproblems/convertToJQuery.html

 It's a dropdown menu with submenu's sliding in from the left.

 regards,


[jQuery] Re: Problem with class attribute: Why this work in 1.2.6 and doesn't work on 1.3.1???

2009-02-26 Thread ricardobeat

What browser are you testing on? Are you using any kind of minifier/
packer?

On Feb 26, 3:46 pm, AndreMiranda acymira...@gmail.com wrote:
 But why (.detalhes) doesn't work and (div .detalhes) works???
 thanks!!

 On 26 fev, 15:44, Eric Garside gars...@gmail.com wrote:

  Actually, the space is telling jquery that you want sub elements, not
  the actual elements.

  a .clickMe will match:

  aspan class=clickMe/span/a

  but not

  a class=clickMe/a

  If you want a tag with a class, you can't add a space.

  On Feb 26, 1:41 pm, brian bally.z...@gmail.com wrote:

   Maybe it's just a typo (and unrelated) but you have spaces in both
   div .detalhes  a .clickMe.

   On Thu, Feb 26, 2009 at 1:27 PM, AndreMiranda acymira...@gmail.com 
   wrote:

$(document).ready(function() {

       //chama a função de Tip
       reiniciaTip();

       //arredonda fundo cinza do DatePicker e da drop down list de
agendas
       $(#divCinza).corner();

       //DatePicker
       $(#divDatePicker).datepicker({
           defaultDate: new Date($(#dataDatePicker).val()),
           changeMonth: true,
           changeYear: true,
           onSelect: function(dataSelecionada){
                       $.ajax({
                               type: 'GET',
                               data: dataSelecionada,
                               url: '/Admin/Agenda/CompromissoAgenda/?
dataSelecionada=' + dataSelecionada,
                               success: function(conteudoAtualizado){
                                           //atualiza os períodos e
compromissos
                                           $(#divPeriodos).empty
().html(conteudoAtualizado);
                                           //reinicia a função de Tip
devido ao callback do ajax
                                           reiniciaTip();
                                        }
                             });
                     }
       });

       //Adiciona a DDL codAgenda na divDDLAgendas da Master
       $(#divDDLAgendas).append($(#codAgenda));
       $(#codAgenda).css({width: '170px'});

});

function reiniciaTip()
{
   $(div .detalhes).each(function(){
       var compromissoId = $(this).attr(id).split(-)[1];
       $(this).bt({
                   ajaxPath: '/Admin/Agenda/DetalhesAgendamento',
                   ajaxData: {data: codAgendamento= +
compromissoId},
                   ajaxOpts: { success: function (data) { return
data.toString(); }},
                   ajaxCache: false,
                   cssStyles: {fontSize: '11px' },
                   width: 220,
                   centerPointX: .9,
                   spikeLength: 35,
                   spikeGirth: 25,
                   padding: 10,
                   cornerRadius: 25,
                   strokeStyle: '#ABABAB',
                   strokeWidth: 1
               });
   });
}

Take a look the function reiniciaTip and the (div .detalhes). In
1.2.6, I just had to write (.detalhes), but now i had to specify
that this is from a div

Thanks!!

On 26 fev, 15:22, Eric Garside gars...@gmail.com wrote:
Can you share your code? The small snippets you've shared indicate no
problem. I threw up the jsbin test to confirm that it's not jquery 1.3
that's causing the error. We can't really help unless you post the
full sample of your code that's broken, or give us a url we can check
out and test.

On Feb 26, 1:18 pm, AndreMiranda acymira...@gmail.com wrote:

 Man, I really don't know why my code is working this way... it's
 frustrating... I really don't wanna go back to 1.2.6...

 On 26 fev, 15:08, Eric Garside gars...@gmail.com wrote:

  Do you have a demo page up somewhere that displays these errors? 
  That
  code looks perfectly valid, and I've not noticed any errors in 
  1.3.1,
  so I'm not sure what could be causing it. I threw up a jsbin test 
  on
  it, and it seems to work fine.

 http://jsbin.com/aputa/edit

  On Feb 26, 1:02 pm, AndreMiranda acymira...@gmail.com wrote:

   Hi Eric!

   I showed this problem with Flexigrid selected rows, but the 
   problem is
   with a specific class attribute to several elements.
   For example, If I have 2 links with class attribute clickMe 
   and I
   do:

   $(.clickMe).click(function(){ alert(this is a test); });

   only the FIRST link works. In 1.2.6 this used to work just fine, 
   but
   in 1.3.1 don't.

   The same code above, to work on 1.3.1 in my projects, I have to 
   do

   $(a .clickMe).click(function(){ alert(this is a test); });   
    I
   had to specify that clickMe is a link (a) class attribute...

   Thanks!!

   On 26 fev, 14:50, Eric Garside 

[jQuery] Re: Issue with .text() and line breaks

2009-02-26 Thread ricardobeat

Just remove them if you need:

$('span').text().replace('\n', '');

- ricardo

On Feb 26, 10:12 am, AdrenalineJunkie jason.h...@gmail.com wrote:
 Im building a form parser(plugin) that will build a json object to a specific
 design.  One problem I am having involves how I render some html and
 subsequently read that html.  I am new to jQuery so please forgive me if I
 am missing something simple.  

 Consider the following snippet
 lt;spangt;some textlt;/spangt;
 jQuery('span').text() yields 'some text' which is what I expect.

 now consider this html snippet
 lt;spangt;some text
 lt;/spangt;
 jQuery('span').text() yields 'some text\n' which is the source of my
 problems with the json2 parser.

 My question is:
 Is there another (best practice) way to get the text from the span (or other
 tags) without the source line breaks?

 --
 View this message in 
 context:http://www.nabble.com/Issue-with-.text%28%29-and-line-breaks-tp37...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Apply class to range of child elements

2009-02-26 Thread ricardobeat

I like it cleaner:

$('a').each(function(i){
   var n = Math.floor(i/10) % 4;
   $(this).addClass(
  n == 0 ? 'first' :
  n == 1 ? 'second' :
  n == 2 ? 'third' :
  n == 3 ? 'fourth' : '');
});

or

var classNames = ['first', 'second', 'third', 'fourth'];
$('a').each(function(i){
   var n = Math.floor(i/10) % 4;
   $(this).addClass(classNames[n]);
});

This also gives you support for infinite expansion. An index of 45
will evaluate to class 'first', 51 to 'second', 85 to 'first' again
and so on.

cheers,
- ricardo

On Feb 26, 6:29 am, mkmanning michaell...@gmail.com wrote:
 And just as an exercise, here's the 'jQuery' way chained:

 $('a').filter(':lt(10)').addClass('first').end().filter(':gt(9):lt
 (10)').addClass('second').end().filter(':gt(19):lt(10)').addClass
 ('third').end().filter(':gt(29)').addClass('fourth');

 Not really any speed gain though.

 On Feb 26, 1:21 am, mkmanning michaell...@gmail.com wrote:

  It's possible. Here's a more traditional way:

          $('a').each(function(i,link){
              if(i10){$(link).addClass('first');}
              else if (i9  i20){$(link).addClass('second');}
              else if (i19i30){$(link).addClass('third');}
                  else if (i29i40){$(link).addClass('fourth');}
          })

  Here's a more 'jQuery' way:
          $('a:lt(10)').addClass('first');
          $('a:gt(9):lt(10)').addClass('second');
          $('a:gt(19):lt(10)').addClass('third');
          $('a:gt(29):lt(10)').addClass('fourth');

  Which is better? The first takes a little over half as long as the
  second.

  On Feb 25, 10:45 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   I have a list of links, around 40 of them.  I want to apply classes to
   groups of them.  So, items 1-10 I want to apply a class to, then
   11-20, then 21-30 and 31-40, each of these groups should have their
   own class.

   Is something like this possible?  I looked through the jQuery
   selectors and could not find a solution.


[jQuery] Re: ?? About the window=this in the source code of the jquery

2009-02-26 Thread ricardobeat

In jQuery's core the *local* variable window is being set. You're
trying to rewrite the global variable 'window' that already exists.
You can only set a var named 'window' in a scope that is not the
global one, like this:

function giveMeChocolate(){
 var window = this;
 //this == the global window object
 window.alert('hmm');
}

Your example rewritten (notice that it's all encapsulated in an
anonymous function, like jQuery):

html
headtitlethis example/title
scripttype=text/javascript
(function(){
  var window=this;
  function dosomething(){
  this.style.color=red;
  };
  window.onload=function(){
document.getElementById(h).onclick=dosomething;
  };
})();
/script
/head
body
hl id=hthis example/h1
/body
/html

The reason this is done is that the Javascript engine will search for
variables from the inside out. See this:

one = 1;

function a(){

  function b(){
 alert(one);
 // first it will check if there is a local var named 'one',
 // if not, it looks for it in the next scope

 // now we'll define a *local* var also named 'one'
 // with a different value
 var one = 2;
 alert(one);
   };
   b();

   alert(one);
   // here 'one' is the global var, there is no 'one' in
   // the current scope

  // and now we define another local var
  // in this function's scope
  var one = 3;
  alert(one);
};

a();

// notice the value of the global 'one' is unchanged
alert(one);

Hope that's clear!

- ricardo

On Feb 26, 6:27 am, tkinter yangbeyonds...@gmail.com wrote:
 I write a code like below to use window=this, but it is wrong!!

 html
 headtitlethis example/title
 script language=Javascript type=text/javascript
 window=this;
 function dosomething(){
         this.style.color=red;
         }

         window.onload=function(){ document.getElementById
 (h).onclick=dosomething; }
 /script
 /head

 body
 hl id=hthis example/h1
 /body
 /html

 the right code is cancel the window=this, why? why use the
 window=this in jquery source code???


[jQuery] Re: HELP: a = $('pfoo/ppbar/p'); a.after('bxyz/b') not adding element

2009-02-26 Thread ricardobeat

after() will insert elements 'after' the selected elements in the DOM.
If the element is not in the DOM, that is kind of 'outer space', there
is no 'after' it. Append and prepend should work just fine:

$('pfoo/ppbar/p')
   .append('b.test/b')
   .prepend('spantest: /span')
   .appendTo('body');

http://jquery.nodnod.net/cases/75

cheers,
- ricardo

On Feb 26, 8:33 am, stephen stephen.cant...@gmail.com wrote:
 Hello,

 has anybody managed to prepend and append elements to a set of dom
 elements previously created on the fly with the $(html) function?

 I've tried with append, prepend, after, before, etc without any
 luck...

 Is there a way to do it?

 Stephen


[jQuery] Re: $('#tab1 tr:gt(0)td').filter(':nth-child(2n+1)') select also 1st td in row - aargghh

2009-02-26 Thread ricardobeat

What are you trying to select (html)?

You're asking for all *odd* td's that are children of the rows.
Indexes in JS start at 0, so the first element is odd. Maybe what you
want is this:

$('#tab1 tr:gt(0)td:nth-child(2n)') or $('#tab1 tr:gt(0)td:even')

If you actually want the odd ones except the first, use :odd:gt(0)
or :odd:not(:first-child)

cheers,
- ricardo

On Feb 26, 6:13 am, ggerri a...@ggerri.com wrote:
 Hi guys

 this drives me crazy.

 why does this also select the first td in each a row?

  $('#tab1 tr:gt(0)td').filter(':nth-child(2n+1)')

 Please give me a hint :-)

 Thanks a lot
 Gerald


[jQuery] Re: Help me!: $(this) ???

2009-02-26 Thread ricardobeat

Oh, I guess the select is not a descendant of the button. It all
depends on the HTML. Try this, if it doesn't work please paste your
html so we can see what's going on.

$(.myButtons).click(function(){
 $(this).parent().find('select').val(1);
  });

- ricardo

On Feb 26, 10:15 pm, Jsudesign jus...@jsudesign.com wrote:
 Hi James, thanks for the response.

 It wasn't that I did try your idea.
 It's something to do with the $(this) part.

 Example:
  $(this).find(select).val('1'); //this will select the option
 with        // Does not work
  $(tr).find(select).val('1'); //this will select the option
 with        //  Works but changes all buttons.

 Any thoughts? Thanks!

 On Feb 26, 5:00 pm, James james.gp@gmail.com wrote:

  You probably need a 'value' attribute assigned to your options. eg.:
  option value=11/option
  option value=22/option

  On Feb 26, 2:45 pm, Jsudesign jus...@jsudesign.com wrote:

   Thanks Ricardo, You are wonderful are understanding my problem.

   After trying your code. The append part works, but the selection part
   does not.

   Any suggestions? Thanks for your help, I'm fairly new to jquery.

   // Code does not work...? hmm

     $(.myButtons).click(function(){
        $(this).find('select').val(1); //this will select the option
   with
           value == 1
     });
    });

   On Feb 24, 11:25 pm, ricardobeat ricardob...@gmail.com wrote:

Probably changing

  $(tr #button).click(function(){...

to this

  $(tr #button).click(function(){
      $(select, this).html(option0/optionoption
selected='selected'1/
optionoption2/optionoption3/optionoption4/
optionoption5/option);
       return false;
      });

Will fix it. You need to find the select element in the right context,
remember that jQuery's selectors work like CSS.

Also I would write your code like this (you don't need to rewrite all
the options just to select one, and you're not setting the option's
values):

$(document).ready(function(){

  $(select).empty().append(
       new Option(0),
       new Option(1),
       new Option(2)
   );

  $(.myButtons).click(function(){
     $(this).find('select').val(1); //this will select the option with
value == 1
  });

 });

From the code your posted one can assume you have multiple elements
with the button ID. That's invalid (IDs should be unique) and will
certainly cause you trouble, use class=something instead.

cheers,
- ricardo

On Feb 23, 9:30 pm, Jsudesign jus...@jsudesign.com wrote:

 Hi everyone,

 I have an add button set up and when you click it it changes the
 selected input from 0 to 1.
 Where my problem is...is that it's doing this for every product.

 Here's an 
 example:http://rickyscentralcitymall.com/ordering/tables.html

 I would add a new class to each product, but that's going to be a pain
 in the end because there are 100+ items on the menu.

 Here's the code I'm working with currently.

 $(document).ready(function(){
 $(select).html(option0/optionoption1/optionoption2/
 optionoption3/optionoption4/optionoption5/option);
         $(tr #button).click(function(){
                         $(select).html(option0/optionoption 
 selected='selected'1/
 optionoption2/optionoption3/optionoption4/
 optionoption5/option);
                         return false;
                         });

  });

 Any help with this would be great.

 Best,
 Justin


[jQuery] Re: fastest way to move dom nodes?

2009-02-26 Thread ricardobeat

This should be a little bit faster:

var $divB = ('.divB', '#wrapper');
$('#divA').children('.a-specific-class').appendTo($divB[0]);

If it's possible, try moving a single wrapper element containing all
the links, that will be certainly faster.

- ricardo

On Feb 26, 8:40 pm, Jack Killpatrick j...@ihwy.com wrote:
 Hi All,

 I have a need to move a few hundred dom nodes from one place in a page
 to another place. For example, to take all link tags inside a div and
 move them to another div, like from divA to divB below:

 div id=divA
     a href=#Link/a
     a href=#Link/a
     a href=#Link/a
     a href=#Link/a
     a href=#Link/a
     a href=#Link/a
 /div

 div id=wrapper
     div class=divB
     /div
 /div

 I'm using jquery 1.3.2 (and have not tried 1.2.6 yet). I've found that
 in FF, Safari and Opera using .append() works OK: the append happens
 fairly fast, but in IE6/7 it's really slow. I'm not sure of the nature
 of the slowdown. My code is something like this:

 var $myContext = $('#wrapper'); // var already available

 var $divB = ('.divB', $myContext);
 $('#divA').children('.a-specific-class').each(function(){
   $divB.append($(this));

 });

 Anyway, I'm wondering if anyone has any advice or best practice to
 recommend for doing something like this, in particular with respect to
 getting decent speed on IE6/7. The speed I'm seeing seems to be ~20-30x
 slower than the other browsers.

 Ideally, I'd like to preserve any event handlers (that some other code
 may have added to the nodes I'm moving), which is why I'm using
 .append($(this)), but it's not completely mandatory if there's no way to
 do so and keep the speed.

 Thanks,
 Jack


[jQuery] Re: How to find a div's which have background-img?

2009-02-25 Thread ricardobeat

This will give you all DIVs which have background-image set:

$('div').filter(function(){
  return !!this.style.backgroundImage;
})

If you need to filter by extension or something use indexOf, it's
faster than a regex:

$('div').filter(function(){
  return this.style.backgroundImage.indexOf('.png')  -1;
})

cheers,
- ricardo

On Feb 25, 6:15 am, David .Wu chan1...@gmail.com wrote:
 I made a function, but I hope I can do it by jquery selectors.

 $(function() {
 $('div').each(function() {
 var $bk = $(this).css('background-image');
 if ($bk.match('png')) {
 console.log('yes');
 } else {
 console.log('no');
 }
 });
 });

 On 2月25日, 下午12時53分, David .Wu chan1...@gmail.com wrote:

  I have hundred or css class need that, I am afraid that it's better to
  search which has the property.

  On 2月25日, 下午12時18分, Steven Yang kenshin...@gmail.com wrote:

   according to your case
   use$(.box)
   or
   $(div .box)
   since all elements with class box will have background image


[jQuery] Re: tbody:first-child thead

2009-02-25 Thread ricardobeat

Tables have native properties which are much faster to access:

$('#myTable')[0].rows.length //number of rows
$('#myTable')[0].tBodies[0].rows.length //number of rows in the first
tbody

cheers,
- ricardo

On Feb 25, 5:25 am, Alex Wibowo alexwib...@gmail.com wrote:
 Hi all,
 I have a code that counts the number of rows in a table...

 the table looks like:

 table id=myTable
   thead
    ...
    /thead

    tbody
         tr
          
         /tr
   /tbody
 /table

 and my jquery looks like:

 $(#myTable  tbody:first-child  tr).length;

 strange enough that always returns 0.
 but if i remove the thead from the table... then it will return the correct
 number of rows..

 or alternatively, i can keep the thead, but use the following instead:

 $(#myTable  tbody  tr).length;

 i.e. without specifying first-child.

 Can anyone explain this behaviour?

 THanks a lot!

 --
 Best regards,

 WiB


[jQuery] Re: Building functions (newbie question)

2009-02-25 Thread ricardobeat

Define the functions in the appropriate scope (either global or inside
the function passed to ready). Functions are executed in the scope
they are called, so you write them like they were already inside the
click handler.

$(document).ready(function() {

 function yourAjaxFunction(){
  ...
  // 'this' in here will be the current element in each()
 };

 $(#paradigm_all).click(function(){
 $(input[name^='paradigm']).each(function(){
 if(this.checked){
 yourAjaxFunction();
 yourCSSFunction();
//here 'this' == this inside the called functions
 }
 });
 });
});

hope that helps.
- ricardo

On Feb 25, 5:00 am, heohni heidi.anselstet...@consultingteam.de
wrote:
 Hi,

 I have some jquery code within the

 $(document).ready(function() {
    $(input:checkbox).click(function(){
          check if checked or unchecked

         ... do some ajax stuff .

          do some css class exchange stuff ..
    });});

 (This is the function to manipulate my code on a single checkbox
 event)

 The ajax part and the css class stuff I want now to surround as
 function in order to use it in another function:

 $(document).ready(function() {
         $(#paradigm_all).click(function(){
         var checked_status = this.checked;
         $(input[name^='paradigm']).each(function(){
                 this.checked = checked_status;
                 if(checked status == true){
                    _call_my_ajax_function();
                    _call_my_css_class_function
                 }
         });
     });});

 (This is the function to manipulate my code when the checkbox check
 all / uncheck all was checked or unchecked)

 To be honest I am a little bit lost in the syntax and not sure how to
 structure it well in order to be able re-using the functions.
 Would be great if someone could give me a hand with it!
 Thanks!


[jQuery] Re: What can we use in place of $.browser?

2009-02-25 Thread ricardobeat

According to John Resig $.browser will remain for the foreseeable
future. Being deprecated doesn't mean it will be removed soon (or at
all). If you're targeting IE6 quirks I'd think it's not that bad to
keep using browser detection, but if you're using it to differentiate
modern browsers it's better to switch to feature detection to make
your code future-proof.

- ricardo


On Feb 25, 2:00 pm, jerone jeron...@gmail.com wrote:
 Then we probably need a plugin for this.
 Because browser detection can also be used for information (not only
 development).


[jQuery] Re: $('#foo p') or $('p', $('#foo'))

2009-02-25 Thread ricardobeat

Up to 1.2.6 that was how it worked.

Kevin: keep using normal CSS selectors. An optimization for this case
(id descendants) has been added to jQuery core yesterday. Most of the
other selectors work faster the normal way $('.myclass something'),
and with this fix $('#id something') will also be as fast as it can.

cheers,
- ricardo

On Feb 25, 3:56 pm, Josh Nathanson joshnathan...@gmail.com wrote:
  First, I *assume* these two statements are identical in performance:
  $(p, $(#foo)) == $(p, #foo)

 No -- the first one calls jQuery three times, the second one twice.  Big
 difference.

 Now, I'm not sure about if it's faster to use find() than the context
 selector.  I would think under the hood it's doing the same thing, and the
 context argument is just a handy shortcut.

 -- Josh

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Kevin Dalman
 Sent: Wednesday, February 25, 2009 10:41 AM
 To: jQuery (English)
 Subject: [jQuery] Re: $('#foo p') or $('p', $('#foo'))

 John wrote: You should always use $(#foo).find(p) in favor of $
 (p, $(#foo)) 

 I'm trying to extrapolate some general concepts from this 'rule'...

 If so, then does it matter what the scope selector is? What if the
 scope is *not an ID*, and therefore not as fast to find, like::

 $(div.myClass).find(p) in favor of $(p, div.myClass) ???

 If this is still true, then my understanding is that $(a).find(b)
 syntax is ALWAYS faster than $(a, b)???

 IF it is true that find() is always faster - or at least equal - to
 specifying a scope selector/element, then it would seem that jQuery
 should simply use the find() flow internally when a scope selector is
 specfied. In other words, when a scope selector/element is specified,
 find this element first and then 'call' the same method used for find
 () - ie:

 *** internally ***
 $(p, $(#foo))  ==  $(#foo).find(p)

 I can't think of any excepts to this - the result should always be
 identical? If so, and performance is equal or superior, then *why not*
 do this internally so the two statements above essentially become 100%
 identical? It would just be two ways of expressing the same thing,
 which is how it appears to users.

 Am I off-base here? If so, which assumuption above breaks down?

 Even if there is a good reason to treat the syntax differently
 internally, I'm still interested to know if I should avoid using scope
 selectors in favor of find() ***under all conditions*** - or only
 under specific conditions?

 /Kevin

 On Feb 24, 5:58 pm, John Resig jere...@gmail.com wrote:
  I want to point out a couple things:
  1) You should always use $(#foo).find(p) in favor of $(p, $
  (#foo)) - the second one ends up executing $(...) 3 times total -
  only to arrive at the same result as doing $(#foo).find(p).
  2) I generally dislike saying that there's one good way to do a
  selector (especially with one that has such bad syntax, as above) -
  especially since it may not always be that way.

  In fact, I've already filed a bug and I'll be looking in to this
  issue, possibly resolving it tonight or tomorrow - at which point the
  advice will be false again.http://dev.jquery.com/ticket/4236

  My recommendation is to always write the simplest, easiest to
  understand, expression: jQuery will try to do the rest to optimize it.

  --John

  On Feb 24, 10:23 am, Stephan Veigl stephan.ve...@gmail.com wrote:

   Hi Karl,

   $('#foo').find('p') and $('p', $('#foo')) are approximately of the same
 speed.

   I've put the test code on JSBin, so everybody can play around with it
   and try other combinations :-)http://jsbin.com/ifemo

   by(e)
   Stephan

   2009/2/24 Karl Swedberg k...@englishrules.com:

Hi Stephan,
Thanks for doing this testing! Would you mind profiling
 $('#foo').find('p')
as well? I suspect it will be roughly equivalent to $('p', $('#foo'))
Cheers,

--Karl

Karl Swedberg
   www.englishrules.com
   www.learningjquery.com

On Feb 24, 2009, at 8:28 AM, Stephan Veigl wrote:

Hi,

I've done some profiling on this, and $(p, $(#foo)) is faster than
$(#foo p) in both jQuery 1.2.6 and 1.3.2.

the test HTML consists of 100 ps in a foo div and 900 ps in a
bar div.

However the factor differs dramatically:
In 1.2.6 the speedup from $(p, $(#foo)) to $(#foo p) was between
1.5x (FF) and 2x (IE),
while for 1.3.2 the speedup is 20x (FF) and 15x (IE).

$(p, $(#foo)) is faster in 1.3.2, by a factor of 1.5 (both FF and
 IE),
while $(#foo p) is _slower_ in 1.3.2 by 8.5x (FF) and 4.6x (IE).

Even with an empty bar div $(p, $(#foo)) is faster by a factor
 up to
3x.

Conclusion:
If you have an ID selector, first get the element by it's ID and use
it as scope for further selects.

by(e)
Stephan
2009/2/23 ricardobeat ricardob...@gmail.com:

up to jQuery 1.2.6 that's how the selector engine worked (from the top

down/left

[jQuery] Re: ~ selector is not selecting siblings

2009-02-25 Thread ricardobeat

There must be something else wrong in your page. The HTML and
selectors you gave work fine (see http://jquery.nodnod.net/cases/175).
Can you put a complete sample page online?

- ricardo

On Feb 25, 8:52 pm, RadicalBender radicalben...@gmail.com wrote:
 The rows are created on the fly, they aren't actually empty.  Here's a
 simplified version of what the table looks like:

 table id=SetListTable cellspacing=0
 trthnbsp;/ththArtist/ththSong/th/tr
 tr id=NoSongs style=display:none;td colspan=4
 class=lastThere are no songs yet./td/tr
 tr id=SongXtda href=javascript:void(0) onclick=DeleteSong
 ()img src=img/delete.png //a/tdtdArtist Name/tdtdSong
 Title/td/tr
 tr id=SongXtda href=javascript:void(0) onclick=DeleteSong
 ()img src=img/delete.png //a/tdtdArtist Name/tdtdSong
 Title/td/tr
 tr id=SongXtda href=javascript:void(0) onclick=DeleteSong
 ()img src=img/delete.png //a/tdtdArtist Name/tdtdSong
 Title/td/tr
 /table

 As you can see, there's a header row, then the NoSongs row, then all
 of the songs are looped over and displayed.

 When there are songs present, NoSongs is hidden. When the select menu
 is changed and no records are returned, NoSongs is made visible again.

 However, when I try to hide and then remove all of the song rows using
 $(#NoSongs ~ tr) to hide all rows after #NoSongs, it's not hiding or
 removing them.

 Hopefully I'm explaining this alright.

 --Ben

 On Feb 25, 5:03 pm, Mauricio \(Maujor\) Samy Silva

 css.mau...@gmail.com wrote:
  Hi RadicalBender,

  How about use the $('tr td:empty') selector to target the empties rows?

  Not solve?
  So,
  need some more information to try figure out a solution.
  Are there tbody, tfoot and thead in your table?
  Where is located the  tr#NoSongs?
  Would you please show a simplified sample of the table markup?

  Maurício

  -Mensagem Original-
  De: RadicalBender radicalben...@gmail.com
  Para: jQuery (English) jquery-en@googlegroups.com
  Enviada em: quarta-feira, 25 de fevereiro de 2009 16:28
  Assunto: [jQuery] ~ selector is not selecting siblings

   I have a table that has a list of songs - one for each row. I also
   have a select menu that populates the song table data from an AJAX
   query based on what was selected.

   The first row of the table is a row (#NoSongs) that just says No
   songs were found. in case no records were returned. And I just hide
   and show that depending on the results.

   Whenever the select menu is changed, it calls a function where the
   logic is like this:

   function ChangeSongs() {

   $(#NoSongs ~ tr).fadeOut('slow',function() {
   $(#NoSongs ~ tr).remove();
   });

   // AJAX Query and a bunch of logic to create new table rows --
   Everything here on works fine.

   }

   The problem is that $(#NoSongs ~ tr) isn't finding any of its
   siblings. So, it just keeps adding new rows without deleting the old
   ones.  And $(#NoSongs ~ tr).size() returns 0 for some reason.

   I could try .siblings() but I only want the rows after #NoSongs
   (there's a table header row as well) and .siblings() returns all
   siblings forward and backward.

   I'm stumped. It should work even if #NoSongs is hidden from view,
   right? I'm really not comprehending why this isn't working.

   Any help would be appreciated. Sorry I can't show the actual code or
   site.


[jQuery] Re: $('#foo p') or $('p', $('#foo'))

2009-02-24 Thread ricardobeat


On Feb 24, 6:10 pm, Jon Sagotsky sagot...@gmail.com wrote:
 Just to clarify, $(p, #foo) would be meaningless

That's not true. $('p', '#foo') has the exact same result as $('p', $
('#foo')), the context is executed just as well.


[jQuery] Re: can jQuery support drawing items on a CANVAS? (e.g. web-based UML tool)

2009-02-24 Thread ricardobeat

Java applets have a bit slow loading time, and afaik it can't interact
with the rest of the page.

Using iecanvas.js you would have to write a single code (compliant
with the canvas specs) that would work for both IE and FF - but the
support in IE might not be complete.

have you seen raphaeljs.com?

cheers,
- ricardo

On Feb 23, 7:47 pm, greghauptmann greg.hauptm...@gmail.com wrote:
 still getting a bit confused with options here, can I ask:

 • re iecanvas.js - is there a way to effectively include this in
 one's project then only write one (1) set of code (javascript, or
 jquery or whatever) such that it will work both on (a) IE and (b)
 firefox?

 • if no, then perhaps at this stage the most solid approach for a
 browser based view of my topology tree would be to use a Java applet.
 comments?

 thanks


[jQuery] Re: Calling method on multiple jQuery objects

2009-02-24 Thread ricardobeat

$('#id')
  .add(myJQObj)
  .add(myotherJQObj)
  .hide()

On Feb 24, 8:51 am, Bisbo michael.waterf...@googlemail.com wrote:
 Hi there,

 I can't seem to find a way to perform the same jQuery method on
 multiple jQuery objects. I have tried using commas and passing arrays
 to the jQuery function but neither works.

 $( $('#id') , myJQObj ).hide();
 $( [ $('#id') , myJQObj ] ).hide();

 I know you can do this within a selector, i.e. $('#id, .hello').hide
 (), but I already have a few jQuery objects passed from various places
 and I need to perform the same action on each of them.

 There must be a way to do this, can anyone point me in the right
 direction as I can't see any way of doing this in the documentation!

 Many thanks,

 Michael


[jQuery] Re: Help me!: $(this) ???

2009-02-24 Thread ricardobeat

Probably changing

  $(tr #button).click(function(){...

to this

  $(tr #button).click(function(){
  $(select, this).html(option0/optionoption
selected='selected'1/
optionoption2/optionoption3/optionoption4/
optionoption5/option);
   return false;
  });

Will fix it. You need to find the select element in the right context,
remember that jQuery's selectors work like CSS.

Also I would write your code like this (you don't need to rewrite all
the options just to select one, and you're not setting the option's
values):

$(document).ready(function(){

  $(select).empty().append(
   new Option(0),
   new Option(1),
   new Option(2)
   );

  $(.myButtons).click(function(){
 $(this).find('select').val(1); //this will select the option with
value == 1
  });

 });

From the code your posted one can assume you have multiple elements
with the button ID. That's invalid (IDs should be unique) and will
certainly cause you trouble, use class=something instead.

cheers,
- ricardo

On Feb 23, 9:30 pm, Jsudesign jus...@jsudesign.com wrote:
 Hi everyone,

 I have an add button set up and when you click it it changes the
 selected input from 0 to 1.
 Where my problem is...is that it's doing this for every product.

 Here's an example:http://rickyscentralcitymall.com/ordering/tables.html

 I would add a new class to each product, but that's going to be a pain
 in the end because there are 100+ items on the menu.

 Here's the code I'm working with currently.

 $(document).ready(function(){
 $(select).html(option0/optionoption1/optionoption2/
 optionoption3/optionoption4/optionoption5/option);
         $(tr #button).click(function(){
                         $(select).html(option0/optionoption 
 selected='selected'1/
 optionoption2/optionoption3/optionoption4/
 optionoption5/option);
                         return false;
                         });

  });

 Any help with this would be great.

 Best,
 Justin


[jQuery] Re: $('#foo p') or $('p', $('#foo'))

2009-02-23 Thread ricardobeat

up to jQuery 1.2.6 that's how the selector engine worked (from the top
down/left to right). The approach used in Sizzle (bottom up/right to
left) has both benefits and downsides - it can be much faster on large
DOMs and some situations, but slower on short queries. I'm sure
someone can explain that in better detail.

Anyway, in modern browsers most of the work is being delegated to the
native querySelectorAll function, as so selector performance will
become more of a browser makers' concern.

- ricardo

On Feb 23, 1:08 pm, Peter Bengtsson pete...@gmail.com wrote:
 I watched the John Resig presentation too and learned that CSS
 selectors always work from right to left.
 That would mean that doing this::

   $('#foo p')

 Would extract all p tags and from that list subselect those who
 belong to #foo. Suppose you have 1000 p tags of them only 100 are
 inside #foo you'll have wasted 900 loops.

 Surely $('#foo') is the fastest lookup possible. Doing it this way
 will effectively limit the scope of the $('p') search and you will
 never be bothered about any p tags outside #foo.

 Or am I talking rubbish?


[jQuery] Re: is there something like $('.myClass').contains('val1 or val2 or val3')?

2009-02-23 Thread ricardobeat

This should work, but it's an inclusive or (unlike an if/else where
only one possibility is choosen)

$('.myclass').filter(':contains(one), :contains(two), :contains
(three)')

On Feb 23, 8:33 am, ggerri a...@ggerri.com wrote:
 Hi guys

 is there a way to use logical operators in jQuery e.g. with
 'contains'?

 thanks


[jQuery] Re: Lower speed with 1.3.1 vs 1.2.6 with simple parsing

2009-02-20 Thread ricardobeat

It's the calls to $(li).find('li.News a') that make for most of the
difference. Without that 1.3.1 is up to 20% faster.

Apparently a simple descendant selector in 1.3 is terribly slower i.e.
$(el).find('div a') if any as exist (even outside the context). Also
'.someclass a' is faster than 'li.someclass a' which doesn't make any
sense. I put a test case at

http://jquery.nodnod.net/cases/142

Guess it has to do with the bottom up traversing approach in Sizzle.

cheers,
- ricardo

On Feb 20, 7:02 am, Sjoland jo...@sjoland.com wrote:
 The markup look like this:

 li class=MenuItem processMenuItem id=MENUID-D
 a href=processing/x/XbrProcessing/a
 ul
 li class=Intro
 h4If you recieve 20,000 invoices per year, you can save at least
 $100,000/h4
 pLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
 eiusmod tempor incididunt ut labore et dolore magna aliqua./p
 /li
 li class=News Disabled
 a href=processing/x/news/ title=News summary.News text.../a
 /li
 li class=Splash Disabled
 a href=processing/x/splash/ title=Splash summary.Splash text.../
 a
 img src=media/splashImage.jpg
 /li
 li class=Anchora href=processing/x/#OverviewOverview/a/li
 li class=Anchora href=processing/x/#Introduction title=We are
 experts in sorting.Introduction/a/li
 li class=Anchora href=processing/x/#ArticleArticle/a/li
 li class=Anchora href=processing/x/#FeaturesFeatures/a/li
 li class=Anchora href=processing/x/#References title=IKEA,
 Porsche, Pfizer, SAS, Tetra Pak, Carlsberg, DaimlerChrysler, LEGO,
 Bosch, DFDS transport, Canon...References/a/li
 li class=Anchora href=processing/x/#TechnicalTechnical/a/
 li
 li class=Anchora href=processing/x/#Integration title=Lorem
 ipsum dolor sit amet.Integration/a/li
 li class=Anchora href=processing/x/#DownloadsDownloads/a/
 li
 /ul
 /li

 The timer looks like this:
 var timer = {
         time: 0,
         now: function(){ return (new Date()).getTime(); },
         start: function(){ this.time = this.now(); },
         since: function(){ return this.now()-this.time; }

 };

 ...and I start the timer in the last row of the last script being
 loaded...

 Yes, I know there are many ways to improve and optimize my methods,
 BUT that's not my main issue right now, becuse any improvment like the
 one Ricardobeat suggests still ends up with less speed in 1.3.1 vs
 1.2.6.

 Thanks,
 /Johan


[jQuery] Re: Using jQuery to Parse XML in AIR

2009-02-20 Thread ricardobeat

It seems you have a misunderstanding here. $(data).text() will get you
the innerText/textContent of all the nodes in your XML, it's not
converting the whole response back to text.

Are you sending the response as 'text/xml' from the server?

add
complete: function(xhr){
console.log(xhr);
}

and check if you have the responseXML property (you can try to use
it's documentElement directly also).

- ricardo

On Feb 20, 3:59 am, s.ross cwdi...@gmail.com wrote:
 Thanks for the reply. Here are  a few results from the callback
 function:

 data = [object Document]
 data.find('category') = TypeError: Value undefined does not allow
 function calls.
 $(data).find('category') = [object Object]
 $(data).find('category').length = 0
 $(data).text() = [text of whole xml document]

 As you can see, the data passed into the function is a first-class
 object, but as the second line illustrates, we can't traverse its DOM
 yet. So, I promote it to a jQuery object using $(data). Doing a find
 ('category') on that produces an object, but the length (I've
 confirmed that it's pretty extensive) still shows up as zero. Noting
 that $(data).text() demotes the object to its textual XML
 representation, I found I could wrap that as:

 $(
   $(data).text()
 )

 which means (to me), forget what you knew about the data object passed
 in and strip it back to bare text, then parse it as an xml document.

 I'm sure I'm making some dumb mistake here, but I just don't see it.
 There's just no reason a library as capable as jQuery shouldn't be
 able to wrap this little problem around its little finger. I'm
 perplexed. But I am also completely sold on jQuery for all my Web
 projects where debugging is at least slightly more sane :)

 On Feb 19, 10:27 pm, mkmanning michaell...@gmail.com wrote:

  I suspect it's the dance you're having to do. Quickly testing in a
  browser, If you use

  xmlObjectTree = $(data)

  then you can iterate through the animal tags.
  Doing the dance in a browser yields an unrecognized expression syntax
  exception. How did you come to use $($(data).text()); and what happens
  if you use the other method?

  On Feb 19, 8:29 pm, s.ross cwdi...@gmail.com wrote:

   I'm trying to get Adobe(TM)(R) AIR to work with jQuery kinda friendly-
   like. I'm sending off an xml-rpc request as follows:

                                   this.packageRequest = function(method, 
   secure, params, callback) {
                                           var msg = new 
   XMLRPCMessage(method);
                                           msg.addParameter(params);

                                           urn = (secure) ? this.SecureUrn : 
   this.Urn;
                                           urn += this.istockEndPoint;
                                           $.ajax({
                                                   url: urn,
                                                   data: msg.xml(),
                                                   dataType: 'xml',
                                                   type: 'POST',
                                                   contentType: 'text/xml',
                                                   success: callback
                                           });
                                   }

   All well and good, and for simple response groups, this works great.
   The callback function is invoked and the xml sanitized. I'm not
   certain why, but I have to do this dance in the callback:

   function myFineCallback(data) {
     xmlObjectTree = $($(data).text());

   }

   The problem I'm really bumping up against is the case where the XML
   looks like:

   root
     animals
       category name=reptiles /
       category name=mammals /
       category name=marsupials /
     /animals
   /root

   You get the picture. The tags have no content. One would expect that:

   xmlObjectTree.find('animals category').each( ... )

   would iterate the animals tags, allowing me to pull the name attribute
   out, but I'm getting a zero-length result. Same for xmlObjectTree.find
   ('category').

   Any thoughts


[jQuery] Re: Jquery Ajax one request, multiple answers problem

2009-02-20 Thread ricardobeat

set cache: false in your $.ajax call to disable cacheing of responses.
You can also add a random query parameter to the URL if that doesn't
work.

- ricardo

On Feb 20, 8:53 am, Jsbeginner jsbegin...@monarobase.net wrote:
 Hello,

 I've been working on a jquery projet (with the lastest stable version of
 jquery) that retrieves information using json from a php script that
 requests information from an API.
 The script lists all the different extensions with a status colomn that
 says what it's doing (waiting, searching or result).
 The script gets the list of extensions form an input select drop down
 that's generated by PHP (this allows me to manage extensions using a
 database). It then launches the search for the selected extension and
 when the search is finished it launches the search for all the other
 extensions.

 I need one answer per query but it seems that the ajax success function
 is launched more than once which is not what I want, also sometimes it
 seems to keep some sort of memory of what the answer was last time (if I
 add a sleep function to the php script sometimes it gets the first
 answer befor the sleep is over) ...

 I've got a php script to check whois servers that replys with either
 taken, available or error.

 When the whois servers answer quickly there are no visible problems, but
 when they are slow the ajax request seems to be launched a second time
 and sometimes a third time when they are very slow.

 So I might see for example : domain.com, status : available, and then 2
 seconds later it will be replaced by domain.com, status : error and
 sometimes then replaced by domain.com, status : available.

 In order to test this I replaced .html( by .append( and I can then
 see all the different results...

 Of course I could check that the html id contains the searching text
 and if not to not change it's value, but I would like to stop it
 launching the search more than once ... !

 Is this a bug or an error in my code ? should I try it with an earlier
 version of jquery ?

 Here is my javascript code :

 function CheckWhois() {
     $('#domchk').submit(function() {
         ls = Array();
         $(#dextoption).each(function(i){
             i = i+1;
             ls[i] = $(this).val();                      
         });
         var ndom = $('#ndom').val();
         var dext = $('#dext').val();
         $(#domresult).html(table
 id=\domtab\trthSel./ththDomain/ththstatus/th/trtrtd
 colspan=\4\Chose TLD/td/trtr class=\chosen\tdinput
 type=\checkbox\ name=\sel\ value=\+ndom+dext+\
 //tdtd+ndom+dext+/tdtd id=\chosenstatus\img
 src=\images/domload.gif\ alt=\en cours ...\ //td/trtrtd
 colspan=\4\Autres Extensions/td/tr/table);
         for ( var e in ls) {
             if (dext != ls[e]) {
                 $(#domtab).append(tr class=\+ls[e]+\tdinput
 type=\checkbox\ name=\sel\ value=\+ndom+ls[e]+\
 //tdtd+ndom+ls[e]+/tdtd id=\status+e+\img
 src=\images/domball.gif\ alt=\waiting ...\ //td/tr);
             }      
         }
         $.ajax({
                 url : scripts/ajaxwhois.php,
                 type : POST,
                 data : domain=+ndom+ext=+dext,
                 dataType : json,
                 error : function (xhr, desc, exception)
 {$(#chosenstatus).html(Error); },
                 success : function (data) {
                     if(data.error) {
                         extd.html(Erreur);
                     } else {
                         $(#chosenstatus).html(data.status);
                         for ( var e in ls) {
                             var extd = $(#status+e);
                             if (dext != ls[e]) {
                                 extd.html(img
 src=\images/domload.gif\ alt=\searching ...\ /);
                                 GetWhois(ndom,ls[e],e);
                             }
                         }
                     }
                 }
             });

         return false;
     });                        

 }

 function GetWhois(ndom,ls,e){
         $.ajax({
             url : scripts/ajaxwhois.php,
             type : POST,
             data : domain=+ndom+ext=+ls+num=+e,
             dataType : json,
             error : function (xhr, desc, exception) {
 $(#status+e).html(Error);},
             success : function (data) {
             if(data.error) {
             $(#status+e).html(Error);
             } else {
             $(#status+data.num).append(data.status);
             }
             }
         });

 }

 $(document).ready(function(){
 CheckWhois();

 });

 Thankyou !


[jQuery] Re: improper function

2009-02-20 Thread ricardobeat

Your function looks fine. The URL given does not exist.

jQuery(function($){
$(#carousel)
 .html( $(#holder_images).html() )
 .carousel3d({
   control: 'continuous',
   radiusY: 0,
   speed: 1,
   radiusX: 250,
   fadeEffect: 1,
   centerX: $('#carousel').offset().left + $
('#carousel').width()/2
  });
});

On Feb 20, 6:46 pm, surreal5335 surrea...@hotmail.com wrote:
 I posted this earlier today, but couldnt find it when I chacked back
 again, I guess it didnt go through all the way.

 I got this code that worked great by itself, but in my site it doesnt
 work, says its an improper function. Does any one have any idea as to
 how to solve this?

 jQuery(function($) {
         $(#carousel).html(
         $(#holder_images).html()).carousel3d({ control: 'continuous',
 radiusY: 0, speed: 1, radiusX: 250, fadeEffect: 1, centerX: $
 ('#carousel').offset().left + $('#carousel').width()/2 });
                 });

 Here is the link to the page that contains this code:

 http://royalvillicus.com/photosite/photo.html

 Thanks a lot for all you help


[jQuery] Re: How to surround All content after a specified HTML attribute H2?

2009-02-19 Thread ricardobeat

Yeah, the browser will try to fix the mark-up you insert. You can't
just treat HTML as text unless you are actually building a string for
inserting via html/append.

cheers,
- ricardo

On Feb 19, 10:16 pm, Charlie Griefer charlie.grie...@gmail.com
wrote:
 Ricardo - thanks for clarifying on the insertion.
 So... when i tried to do $(element).after('div class=foo'); ... was it
 automagically closing the element?  I added $(element).after('div
 class=foobar'); and saw the text bar appear... so even tho it was
 invalid HTML, it still inserted something.  Just curious about what was
 going on there.

 the nextUntil looks -very- cool.

 Thanks,
 Charlie

 On Thu, Feb 19, 2009 at 4:59 PM, Ricardo Tomasi ricardob...@gmail.comwrote:





  You can't insert invalid HTML into the DOM.

  Use the nextUntil plugin by John Resig (I'm starting to think this
  belongs in the core):

  $.fn.nextUntil = function(expr) {
    var match = [];
    this.each(function(){
        for( var i = this.nextSibling; i; i = i.nextSibling ) {
            if ( i.nodeType != 1 ) continue;
            if ( jQuery.filter( expr, [i] ).length ) break;
            match.push( i );
        }
    });
    return this.pushStack( match, arguments );
  };

  then you can do this:

  $('h2').each(function(){
    $(this).nextUntil('h2').wrapAll('div class=contents /');
  });

  cheers,
  - ricardo

  On Feb 19, 8:21 pm, Charlie Griefer charlie.grie...@gmail.com wrote:
   No answer yet.  I've tried playing around with using:$('h2').after('div
   class=someclass');
   $('h2:not(:first)').before('/div');

   but that doesn't seem to be working (and is also problematic because it
   leaves an open div after the last h2).

   it seems that the after() and before() methods each want to insert a full
   element (opened and closed).  i can't tell, but i get the impression that
   jQuery is closing the div class=someclass div automatically.

   hoping somebody else might jump in with a more elegant (and
  correct/working)
   solution.

   On Thu, Feb 19, 2009 at 3:17 PM, cchun...@gmail.com cchun...@gmail.com
  wrote:

Ok i have tried

$('.tabs h2').next().wrapAll('div class=tabbody/div');

but it does not want to wrap all the paragraphs/tables/html in the one
div.

Any ideas?

Thanks for the help!

On Feb 19, 12:21 pm, Charlie Griefer charlie.grie...@gmail.com
wrote:
 actually i should clarify... not change, but wrap the elements
following
 h2 elements with the specified HTML.

 On Thu, Feb 19, 2009 at 10:00 AM, Charlie Griefer 
charlie.grie...@gmail.com

  wrote:
  On Thu, Feb 19, 2009 at 9:27 AM, cchun...@gmail.com 
cchun...@gmail.comwrote:

  I am trying to look through content in a div and if i find an H2
  or
  whatever attribute the content or HTML that follows it will be
  encloded in a div with a class. I will do this for every H2 so if
  i
  have 3 H2's and some paragraphs after them it will surround all
  HTML
  after each of the H2 in a div.

  This will change the element following all h2 elements in the doc.

  script
  $(function() {
   $('h2').next().wrap('div class=someclass/div');
  });
  /script

  If you want it to be just within a certain div, and assuming that
  div
has
  an id attribute of foo, it would be:

  script
   $(function() {
  $('#foo h2').next().wrap('div class=someclass/div');
   });
  /script

  --
  I have failed as much as I have succeeded. But I love my life. I
  love
my
  wife. And I wish you my kind of success.

 --
 I have failed as much as I have succeeded. But I love my life. I love
  my
 wife. And I wish you my kind of success.- Hide quoted text -

 - Show quoted text -

   --
   I have failed as much as I have succeeded. But I love my life. I love my
   wife. And I wish you my kind of success.

 --
 I have failed as much as I have succeeded. But I love my life. I love my
 wife. And I wish you my kind of success.


[jQuery] Re: Counting Lists inside of Lists

2009-02-19 Thread ricardobeat

$(this+ ' li')

'this' is an HTML Element (each LI) and you're trying to concatenate
it with a string. That should be
$(this).find('li').length or
$('li', this).length

Note that the list items are not direct children of this (the parent
LI), so don't use the ''.

cheers,
- ricardo

On Feb 19, 10:14 pm, Tim tim.myer...@gmail.com wrote:
 So I have a main list of states in an unordered list and then a
 unordered list of cities within each of those. So I wanted to count
 the number of cities per state.
 ul class=state_list
 li
         h2Alabama/h2
         ul
             lia href=http://www.google.com;Alabama State/a/li
             lia href=http://www.google.com;Alabama State/a/li
             lia href=http://www.google.com;Alabama State/a/li
             lia href=http://www.google.com;Alabama State/a/li
         /ul
 /li
 /ul

 $('.state_list  li').each(function(i){
                 $(this+ ' li').count();
         });

 It will let me put anything inside of the each function except for
 counting or length, when I do that it blows up the whole site without
 any errors..


[jQuery] Re: iterate through form elements, wait for post to finish and continue

2009-02-19 Thread ricardobeat

You could use a recursive function:

var intervals = $('.interval'), n = 0;

var setDates = function(){
  intervals.eq(n).doStuff(); //intervals.eq(n) is the current element
in the loop
  n++;
  $.post(..., function(){
//...
if (intervals[n])
   setDates(); //re-run the function with the next element
  });
};

setDates();



On Feb 19, 8:33 pm, Mark Steudel msteu...@gmail.com wrote:
 I have the following inputs

     input type=text id=start_date value=2009-01-01 /br/
     input type=text name=a id=a value=3 days class=interval
 rel=a_preview/span id=a_preview/spanbr /
     input type=text name=b id=b value=3 days class=interval
 rel=b_preview/span id=b_preview/spanbr /
     input type=text name=c id=c value=3 days class=interval
 rel=c_preview/span id=c_preview/spanbr /

     input type=button id=assign name=assign /

 The idea is that I have a php script that calculates the date by
 building upon the values that are passed into it.

 So in the (a|b|c)_preview span the expected values would be something
 like:
 2009-01-04
 2009-01-05
 2009-01-06

 I then tried to do something like the following:

 $(document).ready(function(){
             $(#assign).click(function() {
                 $(.interval).each( function() {
                     // save current
                      var previewId = $(this).attr(rel);
                       //alert( previewId );
                      if( $(# + $(#previousStartDate).val()).val() !
 = ''  $(# + $(#previousStartDate).val()).val() != null) {
                          var startDate = $(# + $
 (#previousStartDate).val() ).html();
                      }
                      else {
                          var startDate = $(#start_date).val();
                      }
                      alert( '0-'+previewId);
                      $.post(/scripts/admin.course.php?
 action=calculateDate, {startDate: startDate, nextDate: $(this).val
 ()},function(data){
                          $(# + previewId).html(data);
                           alert( 'i-'+previewId );
                           // save what the previous start date field
 id is
                           $(#previousStartDate).val($(this).attr
 (rel) );
                      });
                });
             })
         })

 What happens (which from what I read is expected) is that I get all of
 the O- alerts and then I get all of the I- alerts. So the dates
 aren't built upon each other.

 What would be a good way to re-do this function so that it waits for
 the previous value before continuing on.


[jQuery] Re: Lower speed with 1.3.1 vs 1.2.6 with simple parsing

2009-02-19 Thread ricardobeat

No idea about the performance drop, but you can improve your main
function:

// MAIN
function getMenuItems(menu) {
  var menuItems = [];
  $(menu).find('.MenuItem').each(function(){
  var t = $(this), item = false;
  if (t.hasClass('processMenuItem')) item = getProcessMenuItem
(this);
  else if (t.hasClass('softwareMenuItem')) item =
getSoftwareMenuItem(this);
  else if (t.hasClass('listMenuItem')) item = getListMenuItem
(this);
  else if (t.hasClass('aboutMenuItem')) item = getAboutMenuItem
(this);
  item = t.hasClass('processMenuItem')
 ? getProcessMenuItem(this)
 : t.hasClass('softwareMenuItem')
   ? getSoftwareMenuItem(this)
   : t.hasClass('listMenuItem')
 ? getListMenuItem(this)
 : t.hasClass('aboutMenuItem')
   ? getAboutMenuItem(this)
   : false;
  menuItems.push(item);
   });
   return menuItems;
};

On Feb 19, 4:18 pm, Sjoland jo...@sjoland.com wrote:
 Hi!,

 When switching between 1.3.1 and 1.2.6 i get a serious drop in speed
 when collection a JSON object from static HTML content.

 1.2.6
 FF: 325ms
 Safari: 75ms
 IE7: 450ms

 1.3.1
 FF: 1205ms
 Safari: 415ms
 IE7: 1550 ms

 The javascript collects data into a JSON object with a few methods
 like this:

 // MAIN
 function getMenuItems(menu) {
         var menuItems = [];
         $(menu).find('.MenuItem').each(function(){
                 var item = false;
                 if ($(this).hasClass('processMenuItem')) item = 
 getProcessMenuItem($
 (this)[0]);
                 if ($(this).hasClass('softwareMenuItem')) item = 
 getSoftwareMenuItem
 ($(this)[0]);
                 if ($(this).hasClass('listMenuItem')) item = 
 getListMenuItem($(this)
 [0]);
                 if ($(this).hasClass('aboutMenuItem')) item = 
 getAboutMenuItem($
 (this)[0]);
                 menuItems.push(item);
         });
         return menuItems;

 };

 // COLLECTOR
 function getProcessMenuItem(li) {
         var type = processMenuItem;
         var item = {
                 id : $(li).attr('id'),
                 type : type,
                 title : $(li).find('a:first').text(),
                 URI: $(li).find('a:first').attr('href'),
                 preamble : $(li).find('li.Intro h4').text(),
                 body : $(li).find('li.Intro p').text(),
                 news : {
                         title : $(li).find('li.News a').text(),
                         URI : $(li).find('li.News a').attr('href'),
                         summary : $(li).find('li.News a').attr('title')
                 },
                 splash : {
                         title : $(li).find('li.Splash a').text(),
                         URI : $(li).find('li.Splash a').attr('href'),
                         summary : $(li).find('li.Splash a').attr('title'),
                         media : $(li).find('li.Splash img').attr('src')
                 },
                 links :  getAnchorLinks(li)
         };
         return item;

 };

 Anyone else experiencing drops in speed with 1.3.1 doing simple stuff
 like this?
 Sure, I was not expecting any major speed increase since the code is
 not optimized yet, but an 80% drop is just crazy...

 Please advice,
 /Johan


[jQuery] Re: Lower speed with 1.3.1 vs 1.2.6 with simple parsing

2009-02-19 Thread ricardobeat

dang. accidentally pressed send while writing, please ignore my last
message.

No idea about the performance drop, but you can improve your main
function. $(this)[0] is unnecessary, you're creating a new jQuery
object and throwing it away.

// MAIN
function getMenuItems(menu) {
  var menuItems = [];
  $(menu).find('.MenuItem').each(function(){
  var t = $(this), item = false;
  if (t.hasClass('processMenuItem'))
  item = getProcessMenuItem(this);
  else if (t.hasClass('softwareMenuItem'))
  item = getSoftwareMenuItem(this);
  else if (t.hasClass('listMenuItem'))
 item = getListMenuItem(this);
  else if (t.hasClass('aboutMenuItem'))
 item = getAboutMenuItem(this);
  menuItems.push(item);
   });
   return menuItems;
};

- ricardo

On Feb 19, 4:18 pm, Sjoland jo...@sjoland.com wrote:
 Hi!,

 When switching between 1.3.1 and 1.2.6 i get a serious drop in speed
 when collection a JSON object from static HTML content.

 1.2.6
 FF: 325ms
 Safari: 75ms
 IE7: 450ms

 1.3.1
 FF: 1205ms
 Safari: 415ms
 IE7: 1550 ms

 The javascript collects data into a JSON object with a few methods
 like this:

 // MAIN
 function getMenuItems(menu) {
         var menuItems = [];
         $(menu).find('.MenuItem').each(function(){
                 var item = false;
                 if ($(this).hasClass('processMenuItem')) item = 
 getProcessMenuItem($
 (this)[0]);
                 if ($(this).hasClass('softwareMenuItem')) item = 
 getSoftwareMenuItem
 ($(this)[0]);
                 if ($(this).hasClass('listMenuItem')) item = 
 getListMenuItem($(this)
 [0]);
                 if ($(this).hasClass('aboutMenuItem')) item = 
 getAboutMenuItem($
 (this)[0]);
                 menuItems.push(item);
         });
         return menuItems;

 };

 // COLLECTOR
 function getProcessMenuItem(li) {
         var type = processMenuItem;
         var item = {
                 id : $(li).attr('id'),
                 type : type,
                 title : $(li).find('a:first').text(),
                 URI: $(li).find('a:first').attr('href'),
                 preamble : $(li).find('li.Intro h4').text(),
                 body : $(li).find('li.Intro p').text(),
                 news : {
                         title : $(li).find('li.News a').text(),
                         URI : $(li).find('li.News a').attr('href'),
                         summary : $(li).find('li.News a').attr('title')
                 },
                 splash : {
                         title : $(li).find('li.Splash a').text(),
                         URI : $(li).find('li.Splash a').attr('href'),
                         summary : $(li).find('li.Splash a').attr('title'),
                         media : $(li).find('li.Splash img').attr('src')
                 },
                 links :  getAnchorLinks(li)
         };
         return item;

 };

 Anyone else experiencing drops in speed with 1.3.1 doing simple stuff
 like this?
 Sure, I was not expecting any major speed increase since the code is
 not optimized yet, but an 80% drop is just crazy...

 Please advice,
 /Johan


[jQuery] Re: Selector difficulty/removeClass

2008-12-12 Thread ricardobeat

And in case you wanted to remove the class only from the label
elements *with* that ID form you would use

$('#quiz label[id*=fb]').removeClass('qyes');

that's plenty of help, isn't it? :)

On Dec 12, 2:25 am, Bruce MacKay b.mac...@massey.ac.nz wrote:
 Hello folks,

 I want to remove a css class (.qyes) from every label element inside
 a single div (id=quiz).

 Each label element has an ID of the form fb*** where *** represents
 a unique identifier (that is not in numerical sequence and is not
 related to the label element's position or order in the div in any way).

 Can someone help me with the necessary selectors to identify the
 label elements in the div (so as to invoke a .removeClass) - I'm
 completely stumped.

 Thanks,

 Bruce


[jQuery] Re: Iterating through .data() elements...

2008-12-12 Thread ricardobeat

There are other alternatives:

1. Store everything as an object in data()

  $(element).data('yourdata',{mydata1:'something,
mydata2:'something'})
  var data = $(element).data('yourdata');
  $(element).data('yourdata', $.extend(data, { mydata3:'something' });

  Then you can iterate over that object's properties.

2. Use the metadata plugin, I think it allows you to iterate over all
data stored

3. keep an 'index array'

  $(element).data('mydata1','something')
  var ind = $(element).data('mydataindex');
  $(element).data('mydataindex', ind.push('mydata1'));


All add extra overhead but it might be a worthy trade-off, and you can
write a custom function (or overwrite 'data') that handles the
extending/indexing for you.

- ricardo

On Dec 12, 1:23 am, Nick nschub...@gmail.com wrote:
 queue as in effect queue?  I'm not finding any documentation on queue
 except as used for effects and your sample seems to put items in a
 queue as if I had to execute things in order.  That's not what I'm
 looking for.  I need to store key/value pairs to specific elements on
 the page for nav requests and data() does this perfectly... I
 currently store they keywords I need in the data element for each list
 item and pass the list item contents to the navigation functions.  If
 I can pass a dynamic set of key/value pairs and iterate through the
 data object to get those values instead of having to know the key,
 then I can fully utilize the framework I'm working with (suppression
 flags, navigation keywords, url variables, etc.)

 I'd hate to have to create a new associative object and pass it when I
 can append the appropriate data to the element when the page is built
 and just pass a reference to the element.

 On Dec 11, 7:28 pm, Ariel Flesler afles...@gmail.com wrote:

  You need to use $().queue() not data.

  $().queue('foo',1).queue('foo',2).queue('foo',3)

  Also, $().queue('foo').each() won't work because the returned data is
  an array.

  $.each($().queue('foo'), function(){ }); will work.

  --
  Ariel Fleslerhttp://flesler.blogspot.com/

  On Dec 11, 7:42 pm, Nick nschub...@gmail.com wrote:

   Does anyone know how I can iterate through the elements stored in the
   data element instead of referring to them individually?

   Say I:
   $(someObj).data('myData1', 'Here is some text')
   .data('myData2', 'Here is some more text')
   .data('myG', 'Here is some more text');

   How could I loop through the data() object to get the key/value pairs
   back if I didn't know the keys?

   I tried:
   $(someObj).data().each(function(i, val) { alert(i + ': ' + val); });

   with no success.  I also tried variations of for loops and such.


[jQuery] Re: getJSON not triggering success callback

2008-12-12 Thread ricardobeat

Check the status in the XHR object you get back, it's probably not
successfull.

On Dec 12, 11:06 am, Javier Martinez ecentin...@gmail.com wrote:
 I'm making some calls with getJSON on another domain, and the callback is
 not firing.
 My code is the next:

 var url = 
 'http://localhost:8080/cometd/cometd?message=%7B%22version%22%3A%221.0...
 '

 $.getJSON(url + 'jsoncallback=?', function() {
 console.log(arguments)

 })

 And this is the response I get in the added script tag

 [{id:0,minimumVersion:0.9,supportedConnectionTypes:[long-polling,callback-polling],successful:true,channel:/meta/handshake,advice:{reconnect:retry,interval:0,timeout:12},clientId:fzmfrqm3f99vdrhow,version:1.0}]

 Somebody can help me with this?

 Thanks.


[jQuery] Re: nextAll Chaining when nextAll is Empty

2008-12-12 Thread ricardobeat

Do you have a test page we can look at?

nextAll returns an empty object if there is no 'next', but it doesn't
interrupt the chain, there may be something else going on. I couldn't
reproduce your situation here, nextAll().andSelf() returns me the
original element.

- ricardo

On Dec 12, 10:39 am, Reepsy mre...@gmail.com wrote:
 This might sound naive, but I expected this to work:

 $(this).nextAll('a').andSelf().removeClass
 ('star_selected').triggerHandler('mouseout');

 It's from a star rating I wrote, where I have 5 a tags in a row. If
 you click on one it removes a class from it and all that follow it,
 and then fires the mouseout event. This works perfectly for stars 1-4,
 but fails on #5, because there is no next. But I did not expect it to
 ignore the rest of the chain. Everything after .nextAll is ignored. If
 I break this into two lines, it works fine:

 $(this).nextAll('a').removeClass('star_selected');
 $(this).removeClass('star_selected').triggerHandler('mouseout');

 But  I am repeating myself with the removeClass. Can anyone see a way
 to combine these back into one statement? The mouseout has to go last.

 Michael


  1   2   3   4   5   6   >