[jQuery] Re: Combine JQuery objects question

2009-07-27 Thread Kean

Why post the question if you had the answer?

On Jul 27, 8:40 am, www.voguemalls.com yuyuhua...@gmail.com wrote:
 who knows if it is possible to join two jQuery objects to make
 a new object.  For example...

 var e1 = $(#firstObject);
 var e2 = $(#secondObject);

 var combined = e1.add(e2);  // This is the expression I'm looking for

 Thanks,

 http://www.voguemalls.com


[jQuery] Re: remove question

2009-06-12 Thread Kean

W3C says that id should not start with a number

Here's probably what you need.

$('#1').remove();


On Jun 11, 7:44 pm, David .Wu chan1...@gmail.com wrote:
 Can I remove div1 but div2 keep there?

 div id=1
 div id=2/div
 /div


[jQuery] Re: css() function returns different results on different browsers

2009-06-12 Thread Kean

It's not really a huge bug and please do submit this as an enhancement
to jQuery tracker.

On Jun 11, 12:57 pm, upsilon upsilo...@gmail.com wrote:
 Hi everyone!

 Today I've tried to create simple hover effect on a div: if the
 cursor is over the box, the background-image css property of the div
 is modified.

 On the HTML side, a div with an id:
 div id=roundpBlah blah/p/div

 On the CSS:
 div#round {
 background-image: url(pics/bg_round.png);

 }

 In order to get the background-image property, I wrote:
 var imgName = $(#round).css('background-image');

 The issue is on what I get from this function in Internet Explorer and
 in Firefox:
 IE : url(http://blabla/images/bg_round.png;)
 FF : url(http://blabla/images/bg_round.png)

 OK, the difference is not huge, and I've already solved the problem by
 replacing quotes by nothing in the string.

 But... Is this a bug? A feature? jQuery is intended for erasing
 differences between browsers, and here it's not the case...
 What do you think of it?

 Thanks!
 upsilon

 PS: sorry for my English (I'm French), I'm afraid that 15 years of
 studies aren't enough for me... :(


[jQuery] Re: binding and re-binding

2009-06-11 Thread Kean

Instead of doing

$(selector).click(function(){});
$(selector).bind('click', function(){});

use

$(selector).live('click', function(){});


On Jun 11, 12:04 pm, Sasha sasha.akh...@gmail.com wrote:
 Hi everyone.  I've run across what must be a common problem:

 When my page loads, I bind every element of a certain class to some
 function (via click, focus, or whatever).  Then I dynamically create
 another element with that same class on the page, and the new element
 lacks the binding.

 Is there a nice shorthand way of saying bind this function to this
 class/id/selector always and forever, no matter whether matching
 elements are created or destroyed?  I'd rather not have to worry about
 re-binding my elements every time I create new ones.

 Thanks! SA


[jQuery] Re: click function on anchor element

2009-06-11 Thread Kean

Interesting! That's also the same with labeling object properties. The
label will be casted into their string representation.

a href=hi.html id=yaasdf/a

$('#ya').click(function(){
   a = {};
   a[this] = 1;
   cache = this;
});

alert(a[cache.toString()]); // alerts 1

On Jun 11, 12:16 pm, Ricardo ricardob...@gmail.com wrote:
 Just clearing up what Pierre said: if the argument you passed to alert
 () is not a string, it's .toString() method will be called. For
 convenience, the toString on an anchor HTMLElement object returns it's
 href. Try this:

 $('a').get(0).toString();
 or
 $('a').click(function(){
    alert( this.toString() );
    return false;

 });

 this in your code is still an object, it's just the output of
 toString() that is different.

 cheers
 -- ricardo

 On Jun 11, 1:10 am, bensan...@gmail.com bensan...@gmail.com wrote:

  Hi all,

  I'm confused as to why when I have:

  $('a').click(function(){
  alert(this);
  return false;

  });

  the alert displays the URL defined in the href attribute, and not an
  object.

  Yet, if i call like say an image, it returns the object.

  Thanks
  ben


[jQuery] Re: Get all unique class names

2009-06-11 Thread Kean

option value=1 class=a/option
option value=1 class=b/option
option value=1 class=c/option
option value=1 class=d/option
option value=1 class=e/option
option value=1 class=f/option
option value=1 class=a/option
option value=1 class=g/option
/body
script language=javascript
var allClassName = $('option').map(function(){
  return this.className;
}).get();

var uniqueClassName = $.unique(allClassName); // returns an array of
unique class name
/script

On Jun 11, 7:01 am, David possum@gmail.com wrote:
 I'm interested in getting an array of unique class names of all option
 tags under a specific select element.

 I'm imagining something like this (which does not do what I want): $
 ( '#select_id option.class' );

 What's the correct way to do this using jQuery?

 Thanks!


[jQuery] Re: ownerDocument is null

2009-06-11 Thread Kean

this[0].ownerDocument

It's used by some functions to create elements that can be appended,
wrapped, inserted into your current element. Meaning the created
elements must match the same document context as the current element.

It can be troublesome when

this[0] === document

as document.ownerDoucment returns null

Please post this in the dev mailing list with a concrete description
of how this can be reproduced.

On Jun 11, 6:19 am, pribis brian.pri...@gmail.com wrote:
 JQuery 1.3.2,  FF3, IE6/7 (not sure of others).

 this[0].ownerDocument is null  Line 4187

 I occasionally get the above error.  It appears that jquery sometimes
 gets a hold of the actual document and so doesn't have an owner
 document.

 Does anyone have suggestions as to what can cause this (or could point
 me to a post that addresses this)?   I've temporarily gotten around it
 by modify jquery to test for null ownerDocument and returning the same
 as if this[0] were null, but I hate to do this since it is probably my
 code that's the problem.

 Thanks

 Brian


[jQuery] Re: How to flip the image?

2009-06-11 Thread Kean

Pretty easy to do with canvas and the JavaScript that came with it.
However, you might have be aware of the compatibility issues
surrounding it.

On Jun 11, 1:16 pm, waseem sabjee waseemsab...@gmail.com wrote:
 I once came across a php class the worked exactly like jquery selectors.
 retrieveing text etc directly into php

 the problem was it made a web page incredably slow. does anyone have
 something a bit more lightweight ?

 On Thu, Jun 11, 2009 at 5:18 PM, Jônatan Fróes jonatanfr...@gmail.comwrote:



  You can make it with PHP. Try this class:
 http://www.verot.net/php_class_upload_samples.htm


[jQuery] Re: calling functions between multiple document ready events

2009-05-29 Thread Kean

@Brian

You might have solve the problem but I don't think polluting the
jQuery namespace is a good thing.

This will work too.

$(function(){
myNamespace = {};
myNamespace.displayMessage = function(){ alert('testing') }; //
works fine

});

$(function(){
myNamespace.displayMessage();

});


On May 29, 1:39 pm, Brian FitzGerald fitzgeraldme...@gmail.com
wrote:
 Hey, thanks a lot for the replies guys.

 Eric, I tried what you suggested, but I was getting javascript syntax
 errors reported.

 So, rather than:

 $(function(){
     $.displayMessage(){ alert('hello world') } // throws js syntax
 errors

 });

 $(function(){
     $.displayMessage();

 });

 I had to do:

 $(function(){
     $.displayMessage = function(){ alert('testing') }; // works fine

 });

 $(function(){
     $.displayMessage();

 });

 I really appreciate you pointing me in the right direction on that.
 With that said, I'm guessing you can't directly declare a function
 in the jQuery namespace like I tried to do in the first example, and
 instead you have to assign a function to a variable handle in the
 jQuery namespace instead, as in the second example?

 Waseem, as far as the suggestion on writing my own plugin, I was
 considering that approach as well, and I may end up going that route.
 The funny thing is, the actual method I'm trying to call is already a
 call off a plugin, so essentially I would be writing a plugin to
 reference another plugin.  Do any gotchas come to mind doing things
 that way, or would that be considered a fairly common practice?

 Thanks again for your thoughts,
 Brian

 Thanks a lot!
 Brian

 On May 29, 3:54 pm, waseem sabjee waseemsab...@gmail.com wrote:

  The easiest way would be to develop your own jquery plugins as plugins are
  able to reference each other even in different files.

  like i have a plugin that allows me to slide left and right.
  then i have a plugin to expand and contract.

  i can call either one in either plugin file.

  On Fri, May 29, 2009 at 8:07 PM, Eric Garside gars...@gmail.com wrote:

   It's a simple scoping problem. Anything you create inside an anonymous
   function will be accessible only within the function. If you need
   something to be accessible between the anon. functions, simply move it
   into a higher scope, like the global namespace (eh, not idea) or the
   jQuery namespace (better idea).

   $(function(){
       $.displayMessage(){ alert('hello world') }
   });

   $(function(){
      $.displayMessage();
   });

   On May 29, 12:18 pm, Brian FitzGerald fitzgeraldme...@gmail.com
   wrote:
I know that you can have more than on document ready event without
difficulty. i.e.

$(function(){
  // document ready 1

});

$(function(){
  // document ready 2

});

The question I have is, is there any way for them to call functions
from one to the other?  The following does not work:

$(function(){
   function displayMessage(){ alert('hello world'); };

});

$(function(){
  displayMessage();

});

This invokes a js error complaining that displayMessage() is not
defined.

Thanks in advance for any thoughts,
Brian


[jQuery] Re: How to disable all clicks till the page loads

2009-05-13 Thread Kean

You can try these.

$().bind('click.noclick', function(){
  return false;
});

$(function(){
  $().unbind('click.noclick');
});

On May 12, 11:56 pm, bobin bobinthoma...@gmail.com wrote:
 Any one can please tell me  How to disable all clicks till the page
 loads

 Any help wil be appreciated


[jQuery] Re: jQuery too slow on IE!!!

2009-05-13 Thread Kean

If speed is paramount to your project and you still want some some
abstraction/cross browser functionality, you can checkout some other
libraries out there.

Here's some comparison on how they perform.
http://dante.dojotoolkit.org/taskspeed/

On May 12, 5:42 am, Chandan learningbychan...@gmail.com wrote:
 Hi,

 I recently started using jQuery, thinking that it is FASTER than usual
 javascript, but i found it is too slow when used with IE. I am using
 IE 6/7.

 I also googled to find lots of posting already happened saying it is
 too slow.

 Can anyone suugest me what needs to be done!

 CC to my friend as well, he is gr8 fan of jQuery.

 Thanks.
 Chandan


[jQuery] Re: how to convert a string to json structure

2009-04-27 Thread Kean

http://www.json.org/
You can find information about the structure, JSON parsers in several
languages etc.


On Apr 27, 1:13 am, gaohk cnga...@gmail.com wrote:
 I have a string that is like [{carePacks:
 [{businessCode:J1PS,description:HP 1}],coveragePeriod:12},
 {carePacks:[{businessCode:J1PS,description:HP
 s}],coveragePeriod:13}].
 can you give me some advice on how to convert it to a json structure,
 and how to get data from the data structure, like get HP 1.


[jQuery] Re: Where to find a jQuery Developer?

2009-04-27 Thread Kean

http://jobs.jsninja.com/

On Apr 27, 9:58 am, nmiddlew...@gmail.com
nmiddlew...@googlemail.com wrote:
 I would rather because I'd also like to learn on the way...

 Are you thinking yourself? Where are you based?

 Thanks,
 Nick

 On Apr 27, 5:35 pm, Joseph Le Brech jlebr...@hotmail.com wrote:

  Does it need to be in london?

   Date: Mon, 27 Apr 2009 09:27:17 -0700
   Subject: [jQuery] Where to find a jQuery Developer?
   From: nmiddlew...@googlemail.com
   To: jquery-en@googlegroups.com

   Hello,

   Does anyone know where I can post a wanted Ad for a London based
   jQuery developer to help me create a jQuery UI component?

   I have a client where I'm creating UI's for but I want future ones
   created in jQuery and I need some help because I can't do it... :)

   Thanks,
   Nick

  _
  Share your photos with Windows Live Photos – 
  Free.http://clk.atdmt.com/UKM/go/134665338/direct/01/


[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Kean

I see a lot of string concatenations. Use this instead.

var str=[];

for(var i=0; i200; i++)
  str.push('table id=a_'+ i + '/table');

$(str.join('')).appendTo('div');

Also, from a performance standpoint, it's much faster to use W3c DOM
methods to create nodes than using the innerHTML method to create
nodes in newer js engines like v8.
You might want to consider a browser detection to do the correct
thing.

On Apr 14, 10:56 am, seasoup seas...@gmail.com wrote:
 I was wondering what jquery developers opinion of adding custom
 attributes to html tags is, and what your basis is for these
 opinions?  Why is it a good idea, or why is it a bad idea?  What I
 mean is this:

 div href= myType=foocontent/div

 where 'myType' isn't in any specifications.  I've run into developers
 who think this is a good idea, and those who think this is a bad idea
 and I'd like to get a better sense of both sides of the argument.
 Personally, I use them all of the time.  They are a great way to
 preserve information for use with .live() in jQuery, among other
 things, and since I append a long string to the DOM instead of
 creating lots of little DOM nodes, I generally cannot use .data() to
 save information on the individual nodes.

 Example of a usage:

 div name=foo myType=barclick/div
 ...
 $('div[name=foo]').live('click', function () {
    console.log($(this).attr('myType'));

 });

 Example of why I cannot use .data():

 var htmlString = 'table';
 for (var a = 0; a  100; a++) {
     htmlString += 'trtd name=clickme nodeId=filter'+ a
 +'click/td/tr';}

 htmlString += '/table';
 $('div[name=foo]').append(htmlString);
 $('td[name=clickme]').live('click', function() {
     console.log($(this).attr('nodeId'));

 });

 To debate the merits of using this kind of append, please go 
 to:http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-cor...

 What I'm looking for instead is a discussion of using custom
 attributes in html.

 Thanks,
 Josh Powell


[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Kean

@Josh Powell
- string concatenation is plenty fast 99% of the time and a lot more
readable.
Yes string concatenation is more readable and 99% faster for normal
usage. But looping and concatenate a huge chunk in this particular
case is slower. Reason: every + between 2 strings returns a new string
before concatenating with other strings. Array.prototype.join does not
have that problem. You just need more than 6 string concatenation
(subject to string length and debate) and it will be a good choice for
Array.prototype.join to take over.

- W3C DOM Node creation is much slower then inserting via innerHTML,
especially as you add more nodes.  It doesn't matter how fast the
nodes are created, it will always be slower to create, adjust, and
insert 10,000 nodes then one string.
That's old school thinking. Please refer to my original post, I am
talking about Chrome's v8 engine and browser detection. You will be
pleasantly surprised. See RobG's comment too.

@RobG
Thanks for benchmarking.


[jQuery] Re: Is it possible to override a link?

2009-02-23 Thread Kean

There are a couple of options, depending on your needs.

$('a#woof').click(function(e){
e.preventDefault();
//do ajax form
});

$('a#woof').click(function(e){
//do ajax form

return false; // preventDefault and stopPropagation
});



On Feb 23, 9:12 am, Frederik Ring frederik.r...@gmail.com wrote:
 This should be working:
 $('a#woof').click(function(e){
 e.preventDefault();
 //do ajax form

 });

 Or you could set all href attributes to '#' before adding the click
 function


[jQuery] Re: A question for John Resig

2009-02-18 Thread Kean

Matt,

While it would not affect the results, I believe you can shave a few
ms off by using  ===

On Feb 18, 11:26 am, Matt Kruse m...@thekrusefamily.com wrote:
 On Feb 18, 6:57 am, John Resig jere...@gmail.com wrote:

  typeof FOO === string
  typeof FOO === number
  typeof FOO === boolean

 == is sufficient. typeof always returns a string.

 Matt Kruse


[jQuery] Re: insert div into group ordered by ID..

2009-02-18 Thread Kean

Just a suggestion, if you just need to sort the elements by id and
displaying their order without modifying the DOM you can totally do
this

alert($('#group div').add('#delta').get().sort(function(a,b) {return
a.id  b.id;}));



On Feb 18, 12:15 pm, Ricardo Tomasi ricardob...@gmail.com wrote:
 I've since updated the script by request, it failed if you began with
 a single element in the container. It now sorts by any attribute you
 want (ids by default) and works with multiple elements both ways.

 http://ff6600.org/j/jquery.insertInOrder.js

 Examples at:http://jsbin.com/itofihttp://jsbin.com/itofi/edit(source)

 cheers,
 - ricardo

 On 22 dez 2008, 15:54, Tbone 95dak...@gmail.com wrote:

  Thanks to you, too, ksunBetween you and Ricardo, I think I
  understand this now!

  On Dec 22, 11:42 am, ksun kavi.sunda...@gmail.com wrote:

   //locate thedivbefore which you want toinsertand theninsert,
   assuming they are ordered alphabetically
                   $('div[id]').each(function(){
                                   if ($(this).attr('id')  'delta')
                                           
   $(this).before('divid=delta/');
                   });

   I think there is no selector that will do the same, but  I may be
   wrong.
   On Dec 22, 12:32 pm, Tbone 95dak...@gmail.com wrote:

Great! Thanks...
However, I'm more clueless than I should be...and didn't pose the
complete question...

I have the divs as shown above, how do I locate where div
id=delta/div would go?
Obviously between gamma and epsilon, but I need to search the ids for
the first (id  delta).  Then I can use yourinsertto properly
place it.  I assume I use a selector, but am not sure how to put it
together.

On Dec 22, 10:25 am, ksun kavi.sunda...@gmail.com wrote:

 try this, it willinsertgamma1 before epsilon.

 $('#gamma~#epsilon').before('divid=gamma1/');

 I first used after(), but that didn't work, looks like $
 ('#gamma~#epsilon') selects #epsilon.- Hide quoted text -

- Show quoted text -


[jQuery] Re: A question for John Resig

2009-02-18 Thread Kean

Seems like my hunch is incorrect, thanks for correcting.

On Feb 18, 12:43 pm, Matt Kruse m...@thekrusefamily.com wrote:
 On Feb 18, 2:20 pm, Kean shenan...@gmail.com wrote:

  While it would not affect the results, I believe you can shave a few
  ms off by using  ===

 Over 10,000,000 iterations, I see no difference in time between using
 == and ===.
 If the return type of 'typeof' varied, a difference might be found.

 It's just a minor quibble anyway. It's similar to lines like this in
 the jquery source:

 if ( typeof text !== object  text != null )

 Fixing things like this would tighten and improve the code a bit, IMO.

 Matt Kruse


[jQuery] Re: Popup going under flash object

2009-01-22 Thread Kean

Problem might be with flash.

add param wmode=transparent
embed wmode=transparent

On Jan 22, 7:36 am, ptmurphy ptmur...@bellsouth.net wrote:
 I have a web page I have been working on and everything looks good in
 IE.  However, in Firefox I am having a problem with the datepicker
 popup window going under a flash object that is below the input field
 on the page.

 The datepicker.css file (this is the only css file I am using in this
 application) sets the z-index to  (which is much higher than
 anything else on the page, and I have set it to as high as 1000
 just to check).  I have tried to set the input field to an extremely
 high z-index, as well as setting the z-index of the flash div to -1.

 Nothing seems to help in Firefox, but IE does everything correctly,
 putting the datepicker popup over the flash object.

 Has anyone run into anything similar and can offer some suggestions?

 Thanks for any help or suggestions...

 PTM


[jQuery] Re: Add Checkboxes in a table.

2009-01-22 Thread Kean

Let me guess, you wanted to add a new row and it is almost identical
to the row before it.

This will probably work.

$row = $('table tr:last-child').clone();
$row.appendTo('table');


On Jan 22, 7:42 am, Andy adharb...@gmail.com wrote:
 I need to be able to dynamically add a new rows to a table and add
 elements such as check boxes, plain text and hyperlinks.  I cannot
 find any examples of this.  Would anyone have any samples or a good
 url?

 Thanks!


[jQuery] Re: how to do '++' in jQuery

2009-01-21 Thread Kean

Probably there's a better way. Doesn't look elegant.

$('xx').width($('xx').width()++) ;

On Jan 21, 2:05 am, David .Wu chan1...@gmail.com wrote:
 some times we want to do some animation we use xxx.width++
 in jQuery we give value like this $('xx').width(value)

 how to do ++ thing in this way?


[jQuery] Re: Selector Help

2009-01-18 Thread Kean

This works and will take care of unchecked conditions too.

$('table tr[id^=row] :checkbox').click(function(){
$$ = $(this);
$text = $$.parent().parent().find('.email, .contact');

if($$.is(':checked')) {
$text[0].value = 'Email Checked';
$text[1].value = 'Contact Checked';
}
else
$checkbox.val('');
});

On Jan 18, 11:41 am, LexHair jdpugl...@hotmail.com wrote:
 I have a table structure with a multiple rows containing a checkbox
 input and 4 text inputs with distinct classes. I want to prefill two
 of the text inputs in the same row where the checkbox is checked.
 Example code for the first two rows:

 table
  tr id=row1
    tdinput type=checkbox //td
    tdinput type=text class=email //td
    tdinput type=text class=contact //td
    tdinput type=text class=realname //td
    tdinput type=text class=sport //td
  /tr
   tr id=row2
    tdinput type=checkbox //td
    tdinput type=text class=email //td
    tdinput type=text class=contact //td
    tdinput type=text class=realname //td
    tdinput type=text class=sport //td
  /tr
 /table

 I need help me crafting the correct selector to focus control onto the
 text input for the input with class=contact and class=email. I can
 write the function to manipulate the attributes but I can't figure out
 the selector. I haven't had any luck with prev ~ siblings or prev +
 next. Thanks in advance.


[jQuery] Re: Selector Help

2009-01-18 Thread Kean

Oops,   $checkbox.val('');  should be $text.val('');

On Jan 18, 1:23 pm, Kean shenan...@gmail.com wrote:
 This works and will take care of unchecked conditions too.

 $('table tr[id^=row] :checkbox').click(function(){
         $$ = $(this);
         $text = $$.parent().parent().find('.email, .contact');

         if($$.is(':checked')) {
                 $text[0].value = 'Email Checked';
                 $text[1].value = 'Contact Checked';
         }
         else
                 $checkbox.val('');

 });

 On Jan 18, 11:41 am, LexHair jdpugl...@hotmail.com wrote:

  I have a table structure with a multiple rows containing a checkbox
  input and 4 text inputs with distinct classes. I want to prefill two
  of the text inputs in the same row where the checkbox is checked.
  Example code for the first two rows:

  table
   tr id=row1
     tdinput type=checkbox //td
     tdinput type=text class=email //td
     tdinput type=text class=contact //td
     tdinput type=text class=realname //td
     tdinput type=text class=sport //td
   /tr
    tr id=row2
     tdinput type=checkbox //td
     tdinput type=text class=email //td
     tdinput type=text class=contact //td
     tdinput type=text class=realname //td
     tdinput type=text class=sport //td
   /tr
  /table

  I need help me crafting the correct selector to focus control onto the
  text input for the input with class=contact and class=email. I can
  write the function to manipulate the attributes but I can't figure out
  the selector. I haven't had any luck with prev ~ siblings or prev +
  next. Thanks in advance.


[jQuery] Re: sorting a select list of option elements

2009-01-16 Thread Kean

Only true arrays will inherit the sort method.

On Jan 16, 10:10 am, brian bally.z...@gmail.com wrote:
 Maybe use makeArray() first. Something like:

 $.makeArray($('#ops-memb option')).sort(...

 On Fri, Jan 16, 2009 at 11:04 AM, mtz tracey.zellm...@gmail.com wrote:

  I have a select list into which I place new option elements, and I
  want to show them in sorted order. I've searched around and tried some
  approaches, but not successful yet.

  Here is an example.
  It may not be the best use of jQuery, but at least I understand it.
  The select element has id ops-memb
  I get the current content, then add another option item.

  var members = $('#ops-memb').html() + option id='507'Another Item/
  option;
  $'#ops-memb').html(members);

  This works.
  Now I try to sort

  $('#ops-memb option').sort(function(a,b) {
   return $(a).text()  $(b).text() ? 1 : -1;
  });

  I get an error message that $('#ops-memb').sort is not a function

  Could someone help me understand what I am doing wrong and how to get
  this to work correctly?

  Thanks.


[jQuery] Re: Smooth page auto scrolling - how to they do this?

2009-01-15 Thread Kean

This is your solution

http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12

On Jan 15, 4:36 pm, Nico nicope...@gmail.com wrote:
 I'm very impressed by this websitehttp://www.blackestate.co.nz/

 Does anyone know a jquery plugin that would allow that smooth page
 auto scrolling behaviour when you click the section links on the left
 hand side?

 thanks,

 n


[jQuery] Re: jQuery website errors

2009-01-14 Thread Kean

Also
http://docs.jquery.com/Frequently_Asked_Questions

On Jan 14, 9:40 am, brian bally.z...@gmail.com wrote:
 FYI, this page currently is throwing a DBQueryError:

 http://docs.jquery.com/UI/Tabs


[jQuery] Re: What am I getting this error?

2009-01-13 Thread Kean

Escape your quotes or use a different quote

Escape quote
var tour-info-div =  '$(\'this\').prev(\'.tour-info-div\')' ;
var update-div   =  '$(\'this\').prev(\'.update-div\')' ;

Use double quote

var tour-info-div =  $('this').prev('.tour-info-div');
var update-div   =  $('this').prev('.update-div');

On Jan 13, 10:25 am, Rick Faircloth r...@whitestonemedia.com
wrote:
 Thanks for the reply, Brian, but that didn't solve it.
 I figured I had a case of quotitus :o)

 Here's what I have now (even took quote out of the top (this))
 and still get the same error:

 $(document).ready(function() {          

    $('.update_button').click(function(){

        var formval        = { tour_url:$(this).prev('.update_input').val(),
                               mls_number: 
 $(this).prev('.tour-div-info').attr('id').val() };
        var tour-info-div  = $(this).prev('.tour-info-div');
        var update-div     = $(this).prev('.update-div');

         etc...

 Any other ideas/suggestions?

 Thanks,

 Rick

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of brian
  Sent: Tuesday, January 13, 2009 12:39 PM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: What am I getting this error?

  You have too many quotes in these 2 lines:

  var tour-info-div =  '$('this').prev('.tour-info-div')' ;
  var update-div       =  '$('this').prev('.update-div')' ;

  try:

  var tour-info-div =  $(this).prev('.tour-info-div') ;
  var update-div       =  $(this).prev('.update-div');

  On Tue, Jan 13, 2009 at 12:29 PM, Rick Faircloth
  r...@whitestonemedia.com wrote:

   Hi, all...

   Why am I getting this error:

   missing ; before statement
   var tour-info-div = '$('this').prev('.tour-info-div')' ; \n

   from this code: ???

   $(document).ready(function() {

     $('.update_button').click(function(){

        var formval          =  { tour_url: 
   $('this').prev('.update_input').val() ,
                                  mls_number: 
   $('this').prev('.tour-div-info').attr('id').val() } ;
        var tour-info-div =  '$('this').prev('.tour-info-div')' ;
        var update-div       =  '$('this').prev('.update-div')' ;

        $.ajax({     cache: false,
                      type: POST,
                       url:  
   ../components/virtual_tours.cfc?method=update_tourreturnFormat=json,
                  dataType: json,
                      data: formval,
                   success: function(response) {

                            if (response.update == Update Successful)
                               { $('update-div').hide();
                                 $('tour-info-div').load(???).show(); }
                            else
                               { 
   $('#unsuccessful').empty().fadeIn(500).append(response.update) };

                            }

        });
     });
   });


[jQuery] Re: Code simplification?

2009-01-13 Thread Kean

Try this if you can't change your html

(function($) {
  $.fn.replaceClass = function(class1, class2){
$(this).removeClass(class1).addClass(class2);
  }
})(jQuery);


$('.nav_company').hoverIntent(function() {
// toggle display of company sub menu content panel
$
('.nav_sub_default, .nav_sub_products, .nav_sub_markets, 
.nav_sub_tools_support, .nav_sub_news_events').replaceClass
('onscreen', 'offscreen');
$('.nav_sub_company').replaceClass('offscreen', 'onscreen');

  },

  function(){
return false;
  }
);

On Jan 13, 8:36 am, r...@lighthouseuk.net r...@50-tuning.com
wrote:
 Hi,
 I'm new to jQuery and liking what I've seen so far.

 I'm curious as to whether I can reduce my code, using chaining
 perhaps?

 Example...

 $('.nav_company').hoverIntent(function() { // toggle display of
 company sub menu content panel
         $('.nav_sub_default').removeClass('onscreen').addClass
 ('offscreen');
         $('.nav_sub_company').removeClass('offscreen').addClass
 ('onscreen');
         $('.nav_sub_products').removeClass('onscreen').addClass
 ('offscreen');
         $('.nav_sub_markets').removeClass('onscreen').addClass
 ('offscreen');
         $('.nav_sub_tools_support').removeClass('onscreen').addClass
 ('offscreen');
         $('.nav_sub_news_events').removeClass('onscreen').addClass
 ('offscreen');
       },function(){
         return false;

 });

 Based on the fact that there are 6 menu items (nav_sub_x) - I
 currently have the above code entered 6 times to add and remove the
 necessary classes from each of the relevant DIVs on the page.

 Is there a cleaner way to do this?
 Many thanks in advance.
 Cheers,
 Rob


[jQuery] Re: @name deprecated?

2009-01-13 Thread Kean

Yes

On Jan 13, 1:10 pm, Micky Hulse rgmi...@gmail.com wrote:
 Does this:

 $('inp...@name=status]').attr($attr_options_01);

 Need to be this:

 $('input[name=status]').attr($attr_options_01);

 With the latest version of jQuery?

 I was reading somewhere on this group about this type of change?

 Any other similar changes I should be aware of?

 Thanks!
 Micky


[jQuery] Re: $(window).bind('resize', fn) not working in IE

2009-01-13 Thread Kean

try

$(window).resize(fn);

On Jan 13, 3:54 pm, sam sam.from.hackern...@gmail.com wrote:
 Can anyone verify that $(window).bind('resize', fn) doesn't work in
 IE?  $(window).bind('scroll', fn) works fine for me, but not resize.

 I'm using 1.2.6.

 Thanks.


[jQuery] Re: Can't figure out how to traverse the DOM to these values...

2009-01-13 Thread Kean

So far reading all your post today points to one thing in common.

You don't really distinguish between types of objects (ie array,
string, objects etc)
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference

Go there and learn about objects first. Hope it helps.



On Jan 13, 5:04 pm, sam sam.from.hackern...@gmail.com wrote:
 I didn't read your whole post.

 However, you should read the docs to be sure functions are returning
 what you think they are returning.

 jQuery.attr(one param) will return a String of that attribute...
 so you cannot then call .val() because .val() is not a method that
 String has.

 jQuery.val() should work just fine for form inputs.

 jQuery.next(selector) returns the next SIBLING elements to each
 jQuery.  If you're looking for elements inside jQuery then
 use .find().

 Hope this helps.

 -sam

 On Jan 13, 7:29 pm, Rick Faircloth r...@whitestonemedia.com wrote:

  Starting from the input with the class update-button
  in the next to the bottom line of the HTML/CFML below,
  I'm trying to traverse one line up to the input with two
  classes, the second being the important one, update-input.

  I've tried using:
  $('.update-button).parent().next('.update-input').attr('value').val()
  to get the form field input placed into the field by the user.  In other 
  words,
  I'm trying to get the value the user puts into the field, which is the tour 
  url.

  The next value I need to send via ajax is top div's id value on the first
  line below of the HTML/CFML.  It's the div with a class of tour-info-div
  and I need it's id value, which is the mls_number.  The #mls_number# is a
  ColdFusion variable.  For this one, I tried:
  $('.update-button).parent().parent().attr('id').val()
  but I was getting an error on that one.

  I need to send those two values, the form field tour url user entry, and the
  mls_number as values through the ajax function.

  How would I write up these traversals?

  Thanks for any help!

  Rick

  Here's the HTML/CFML:

  div id=#mls_number# class=tour-info-div

     div id = address_id_#mls_number# style=width:300px; 
  font-weight:bold;#street_number#
  #street_name#, #city#/div

     cfif not len(trim(#tour_url#))
        div class=no-tourNo Tour Available/div
     cfelse
        div class=tour-urlCurrent Tour: nbsp; #tour_url#/div
        div class=options
              [ a href=#tour_url# target=_blankPreview/a ] nbsp;
              [ a class=update-link href='##'Update/a ] nbsp;
              [ a href= ##Delete/a ]
        /div
     /cfif

     div class=update-div

        divEdit Link:/div
        divinput class=textinput01 update-input size=80 
  value=#tour_url#/div
        divinput class=update-button type=button value=Update/div

     /div

  /div


[jQuery] Re: createElement, get its value

2009-01-13 Thread Kean

Hmmm, you must understand event listener(bind) does not work like CSS
where DOM nodes added in the future cannot be listened right now.
That's where event delegation comes it.

http://www.learningjquery.com/2008/03/working-with-events-part-1



On Jan 13, 4:58 pm, sam sam.from.hackern...@gmail.com wrote:
 $('#grabMe') will search the document for an element with ID grabMe

 Have you added grabMe to the document?

 On Jan 13, 6:00 pm, CrustyDOD anze.stok...@gmail.com wrote:

  Hey!

  I've created one div with FlyDOM plugin which uses createElement
  function to add stuff to DOM. Now the problem is that once i add the
  element, i cannot access it in anyway.

  For example with FlyDOM plugin i create:
  div id=grabMeIt works!/div

  After the JS for creating element i have this:
  $('#grabMe').click(function() {
      alert($(this).html());

  });

  It doesn't work.

  There are no errors shown in Firebug, the element is in DOM, id is
  set. It's all there.

  Am i missing something here? I'm confused :S

  Using jquery 1.2.6


[jQuery] Re: Capture a click outside of a specific object?

2009-01-13 Thread Kean

You might want to look at live and die method now posted in jQuery
documentation.

On Jan 13, 11:32 am, riotbrrd k...@riotbrrd.com wrote:
 Hi all,

 Is there a simple way to capture a click event in a window/document
 and then determine whether the click was inside an element #foo, or
 outside of that element?

 Thanks!
 -Kim


[jQuery] Re: createElement, get its value

2009-01-13 Thread Kean

using jQuery 1.3

This will most probably work.

$('#grabMe').live('click', function() {
alert($(this).html());
});

On Jan 13, 5:41 pm, Kean shenan...@gmail.com wrote:
 Hmmm, you must understand event listener(bind) does not work like CSS
 where DOM nodes added in the future cannot be listened right now.
 That's where event delegation comes it.

 http://www.learningjquery.com/2008/03/working-with-events-part-1

 On Jan 13, 4:58 pm, sam sam.from.hackern...@gmail.com wrote:

  $('#grabMe') will search the document for an element with ID grabMe

  Have you added grabMe to the document?

  On Jan 13, 6:00 pm, CrustyDOD anze.stok...@gmail.com wrote:

   Hey!

   I've created one div with FlyDOM plugin which uses createElement
   function to add stuff to DOM. Now the problem is that once i add the
   element, i cannot access it in anyway.

   For example with FlyDOM plugin i create:
   div id=grabMeIt works!/div

   After the JS for creating element i have this:
   $('#grabMe').click(function() {
       alert($(this).html());

   });

   It doesn't work.

   There are no errors shown in Firebug, the element is in DOM, id is
   set. It's all there.

   Am i missing something here? I'm confused :S

   Using jquery 1.2.6


[jQuery] Re: Old code not working with new 1.2.6

2009-01-12 Thread Kean

jQuery 1.3 is going to be released soon. You might want to try to see
if it works with 1.3b2.

Also, it might be helpful to publish snippets of html that relates to
your query.

On Jan 12, 11:27 am, bryce4president brycekmar...@gmail.com wrote:
 I had a piece of code that worked with 1.2.2 but now it doesn't seem
 to work with 1.2.6

 Here is the code, can anybody see anything that would cause it to stop
 working?  All it does is adds a link to a piece of text in a table
 cell.

 $('#'+i).children('td:first').next().click(function(){
 ord = $(this).text();
 window.location.href = Recap?ord=+ord+pg=+page;

 });

 It doesn't seem to be picking up the right part of the DOM anymore...


[jQuery] Re: Any trick to making text at has been faded in look good?

2009-01-12 Thread Kean

Learned something today.. it's nice to know that the filter attribute
is causing the problem and to remove it when finished with the
animation.

On Jan 12, 10:09 am, Rick Faircloth r...@whitestonemedia.com
wrote:
 Thanks for the reply, Mauricio, but I couldn't get
 your solution to work.

 Adding the background (at least in IE 7) didn't have any effect
 on the display of the final text.

 Also, on your demo page, I got an error.  Looking at the code,
 I think you've got a no-background class on both demo p's.

 Rick



  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of Mauricio
 (Maujor) Samy
  Silva
  Sent: Monday, January 12, 2009 12:03 PM
  To: jquery-en@googlegroups.com
  Subject: [jQuery] Re: Any trick to making text at has been faded in look 
  good?

  Are you talking about Internet Explorer browser?
  If so, have a look in the following article:
 http://www.kevinleary.net/blog/jquery-fadein-fadeout-problems-in-inte...

  Maurício

  -Mensagem Original-
  De: Rick Faircloth r...@whitestonemedia.com
  Para: jquery-en@googlegroups.com
  Enviada em: segunda-feira, 12 de janeiro de 2009 14:44
  Assunto: [jQuery] Any trick to making text at has been faded in look good?

   Hi, all...

   I prefer to use .fadeIn(500), etc., to bring elements
   onto a page, as it gives the user a chance to keep
   up with changes being made visually.

   However, .fadeIn leaves text looking *u-ga-ly*... changing
   .fadeIn to .show leaves text nicely rendered in the browser.

   Is there some trick or other way to cause the browsers to
   render text that has been faded in looking good?

   Rick


[jQuery] Re: Problem with creating dynamic html...

2009-01-12 Thread Kean

in 1.3 it will be something like this

$(),live('click', function(){

});


or you can do something like this in 1.2.6

$().click(function(e){
  e = e.target || e.srcElement;

  if $(e).is('CSS selector')
 fire the function

});

adding some bubbling

$().click(function(e){
  e =e.target || e.srcElement;
  obj = e;
  ancestors = [];

  while(obj) {
ancestors.push(obj);
obj = obj.parentNode;
  }

  if $(ancestors).is('CSS selector')
 fire the function
});

still needs a lot of work but should be a starting point. Good luck.

On Jan 12, 4:13 am, Nedim nedi...@gmail.com wrote:
 Thank you.
 I will check it later.

 On Jan 11, 3:01 pm, Mike Alsup mal...@gmail.com wrote:

   This is in html (by default)

         input type=hidden id=brojacgrupa value=1 /
         div id=grupe
            div id=grupa1 class=grupa
                input type = hidden id=grupa1 value=1/
                  div class=dodatni-sastojcispan class=naslov-
   posKolicina/span span class=kolicina-posNaslov/span/div

                   div id=grupa-sadrzaj
                       div id=grupa-list
                       div
                           div class=dodani-sastojciinput
   name=vrijednosti[][1][kol] type=text title=Količina npr. 100ml,
   10 kom i sl. / /div
                           div class=dodani-sastojciinput
   name=vrijednosti[][1][naziv] type=text title=Primjer: U polje
   količina unesete 10 kom, a u naslov jaja.  //div
                            div class=dodani-clear/div
                       /div
                   /div

                           span class=novisastojakDodaj sastojak/
   span/div
                /div
          /div

     div id=grupanovi /div
          span id=novagrupaNova grupa/span

   When i click on grupanovi it creates:

   $('#grupanovi').append('div id=grupediv
   id=grupa'+document.getElementById('brojacgrupa').value+'
   class=grupainput type = hidden id=grupa'+document.getElementById
   ('brojacgrupa').value+' value='+document.getElementById
   ('brojacgrupa').value+'/div class=dodatni-sastojcispan
   class=naslov-posKolicina/span span class=kolicina-posNaslov/
   span/divdiv id=grupa-sadrzajdiv id=grupa-listdivdiv
   class=dodani-sastojciinput name=vrijednosti[][1][kol]
   type=text title=Količina npr. 100ml, 10 kom i sl. / /divdiv
   class=dodani-sastojciinput name=vrijednosti[][1][naziv]
   type=text title=Primjer: U polje količina unesete 10 kom, a u
   naslov jaja.  //divdiv class=dodani-clear/div/div/
   divspan class=novisastojakDodaj sastojak/span/div/div/
   div');

   But this works only on default:

    $(.novisastojak).click(function(){
             alert('testiram');

            });

   not on dynamical content created.

   Help?

             });

  Here's two resources you should read:

 http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_st...

 http://www.learningjquery.com/2008/03/working-with-events-part-1

  Note that with the soon-to-be-released 1.3 version of jQuery this
  situation will be much easier to handle.

  Mike


[jQuery] Re: Any trick to making text at has been faded in look good?

2009-01-12 Thread Kean

Look at Mike Alsup's solution

On Jan 12, 1:37 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 Can you be more specific?  Are you saying the filter attribute
 causes IE to poorly render fades?

 If so, what does your coding solution look like?

 $('#dogs').fadeIn(500).attr('filter', '') ???

 Rick

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of Kean
  Sent: Monday, January 12, 2009 4:08 PM
  To: jQuery (English)
  Subject: [jQuery] Re: Any trick to making text at has been faded in look 
  good?

  Learned something today.. it's nice to know that the filter attribute
  is causing the problem and to remove it when finished with the
  animation.

  On Jan 12, 10:09 am, Rick Faircloth r...@whitestonemedia.com
  wrote:
   Thanks for the reply, Mauricio, but I couldn't get
   your solution to work.

   Adding the background (at least in IE 7) didn't have any effect
   on the display of the final text.

   Also, on your demo page, I got an error.  Looking at the code,
   I think you've got a no-background class on both demo p's.

   Rick

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
Behalf Of Mauricio
   (Maujor) Samy
Silva
Sent: Monday, January 12, 2009 12:03 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Any trick to making text at has been faded in 
look good?

Are you talking about Internet Explorer browser?
If so, have a look in the following article:
   http://www.kevinleary.net/blog/jquery-fadein-fadeout-problems-in-inte...

Maurício

-Mensagem Original-
De: Rick Faircloth r...@whitestonemedia.com
Para: jquery-en@googlegroups.com
Enviada em: segunda-feira, 12 de janeiro de 2009 14:44
Assunto: [jQuery] Any trick to making text at has been faded in look 
good?

 Hi, all...

 I prefer to use .fadeIn(500), etc., to bring elements
 onto a page, as it gives the user a chance to keep
 up with changes being made visually.

 However, .fadeIn leaves text looking *u-ga-ly*... changing
 .fadeIn to .show leaves text nicely rendered in the browser.

 Is there some trick or other way to cause the browsers to
 render text that has been faded in looking good?

 Rick


[jQuery] Re: i don´t know how add css to my html wit h jquery.

2009-01-11 Thread Kean

Do not use jQuery 1.2.5, use 1.2.6 instead.

On Jan 11, 2:19 pm, Mauricio \(Maujor\) Samy Silva
css.mau...@gmail.com wrote:
 The css() jQuery method has two sintaxes.

 For one css declaration use:
 $('#contenido').css('float', 'left');

 For multiple css declarations use:
 $('#contenido').css ({
      float: 'left',
     width: '480px',
     min-height: '250px',
     ...,
     backgroundColor: '#fff'
     });

 See:http://docs.jquery.com/CSS/css#properties

 Maurício

 -Mensagem Original-
 De: goosfancito goosfanc...@gmail.com
 Para: jQuery (English) jquery-en@googlegroups.com
 Enviada em: domingo, 11 de janeiro de 2009 18:07
 Assunto: [jQuery] i don´t know how add css to my html with jquery.

 Hello all!

 I have this .html
 -
     script language=JavaScript type=text/javascript src=jvs/
 jquery-1.2.5.js /script

 script type=text/javascript
 $(document).ready(function(){

 $(p).click(function(event){
 alert(Thanks for visiting!);});
 });

     /script

 /head

 body
 div id=contenidos
         pEscoger del menu/p
     /div

 /body

 /html

 --- eof 8 

 and i have this other .css:

 -
 #contenidos{
     float:left;
     width:480px;
     min-height: 250px;
     border: 3px solid grey;
     margin-left: 10px;
     padding: 5px;
     padding-bottom: 8px;
     background-color: #fff;

 }

 -EOF 8-

 my question. How i do to used this .css file in  my .html with jQuery¿

 Thank´s


[jQuery] Re: mouseOut problem, tip not dissapearing

2009-01-07 Thread Kean

In the hide img function just call hide tip.

On Jan 7, 8:53 am, i...@wenn.com i...@wenn.com wrote:
 We have a page that when you hover over images the tooltip shows, when
 you click on the image, the list of images is hidden but the tip seems
 to still say on the screen till i move mouse over another object that
 has a tip on it.

 Is there any way around this problem?


[jQuery] Re: event.preventDefault() not in the intellisense?

2009-01-04 Thread Kean

Hmm, sounds like a visual studio bug.

Usually you just return false instead of doing  e.preventDefault()
when coding with jQuery.

i.e.

$('a').click(function(){
  alert('clicked');

  return false; // prevent default
});

On Jan 3, 7:54 pm, yww yww...@gmail.com wrote:
 Hi I am new to this group and also new to Jquery.
 So I am just trying the sample in tutorials. Basically it works very
 nicely.
 But there is a small flaw while I was playing with JQuery,
 that I can't get the intellisnse help from visual studio. and I have
 captured the screen shot as following:

 http://picasaweb.google.com/lh/photo/i6GxK88a7vxrQR9qS8BARQ?feat=dire...

 so you see I have add reference to jquery-1.2.6-vsdoc.js, but there is
 no  preventDefault() method for  event object. What should I do to
 enable that?

 by the way, although the method was not listed, it can be used
 correctly and really prevented the click event.


[jQuery] Re: How to force a child page to open in iframe using jquery

2009-01-04 Thread Kean

The site used a frame braker for a reason, which is, I do not want my
site be in someone elses frame. Please respect that or contact that
site admin.

On Jan 4, 2:43 am, AbhishEk mithuabh...@gmail.com wrote:
 plz help

 On Fri, Jan 2, 2009 at 5:44 PM, AbhishEk mithuabh...@gmail.com wrote:
  actually , the written javascript directly checks the url of browser nd if
  it finds a dff , it fires a location.replace command .
  Plz suggest how can i stop this default behaviour.

  On Fri, Jan 2, 2009 at 6:51 AM, Ricardo Tomasi ricardob...@gmail.comwrote:

  If the iframe has access to the parent frame it's on the same domain,
  then you have access to it right? I think there's nothing you can do
  to stop that.

  On Jan 1, 8:24 am, AbhishEk mithuabh...@gmail.com wrote:
   Hi,
   I have a WebPage on which i have an iframe inside which i open child
  pages .
   In one of the child pages following script is written

   script type=text/javascript
       if (self != top) {
       if (window.location.href.replace)
           top.location.replace(self.location.href);
           else
               top.location.href=self.document.href;
               }
    /script

   Which replaces my original url to its url and my page is gone ..
   is there any way using jquery that i can stop this page from bursting my
   iframe.

   Plz Help.

   Thanks in advance
   ~abhi


[jQuery] Re: jQuery way

2009-01-04 Thread Kean

This might be shorter.

$(#container  :not(#header, #content, #footer)).empty();

- Kean

Tested with Sizzle but not jQuery 1.2.6

On Jan 4, 11:08 am, John Resig jere...@gmail.com wrote:
 Maybe:
 $(#container).children().not(#header, #content, #footer).empty();

 --John

 On Sun, Jan 4, 2009 at 2:05 PM, Dirceu Barquette

 dirceu.barque...@gmail.com wrote:
  Hi all!

  Is there better way?

  var elem = $('#container')[0];
  var  arr = [header,content,footer];
  jQuery.each(elem.childNodes,function(k,v) {
     if (jQuery.inArray(v.id, arr)  0) {
        $(v).empty();
     }
  })

  thanks

  Dirceu Barquette


[jQuery] Re: what's wrong with $(:checkbox[checked=true]) ?

2008-12-31 Thread Kean

Correct me if I am wrong but I believe :checked works on checkboxes
only, hence

$(:checked)  is sufficient.


On Dec 31, 7:59 am, Karl Swedberg k...@englishrules.com wrote:
 not sure, but this works, too:

 $(:checkbox[checked])

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com

 On Dec 31, 2008, at 6:29 AM, Andy Fish wrote:



  Hi,

  I was trying to select for checked checkboxes so I tried
  $(:checkbox[checked=true])

  this never returns anything, even though if I select all checkboxes I
  can test this.checked for each one and it returns true/false as
  appropriate.

  I now understand that I can to :checkbox:checked, but I don't
  understand why my original approach doesn't work, since clearly each
  checkbox has an attribute 'checked' which has the value true or false.

  Andy


[jQuery] Re: Problem link,href,tree, etc.

2008-12-31 Thread Kean

I think jQuery 1.3 will solve this problem by

$('.teryt').live('click', (function(){
   $('#miejscowosci-wybierz-wyniki').load($
 (this).attr('href'));
 return false;
   });
});


On Dec 31, 10:35 am, Karl Swedberg k...@englishrules.com wrote:
 Not a problem at all. Glad to help.

 --Karl

 On Dec 31, 2008, at 1:31 PM, vcs wrote:



  Very very thank this is it:) Sorry :)

  On 31 Gru, 18:50, Karl Swedberg k...@englishrules.com wrote:
  Hi there,

  It sounds like your problem could be addressed by one of the  
  solutions
  offered 
  here:http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_st
  ...

  --Karl

  
  Karl Swedbergwww.englishrules.comwww.learningjquery.com

  On Dec 31, 2008, at 12:45 PM, vcs wrote:

  This should be a recursive construction (maybe nesting while-loops)
  responding at every mouse click. But I cannot do it. It should be
  simple. jquery fetches 'href' attribute value from clicked link and
  should load data. So when #miejscowosci-wybierz-wyniki link is
  clicked, I expect to have new group of links loaded which is
  associated with mentioned link. When I click on #miejscowosci-
  wybierz-
  wyniki again I expect to have new data loaded again and jquery  
  should
  fetch 'href' attribute value again and return it to #miejscowosci-
  wybierz-wyniki (same link). It's all about losing recursion. When
  data has been loaded after first click, those links are beginning to
  point real targets, and jquery do not work on them anymore.

  On 31 Gru, 17:12, Joe joseph.is...@gmail.com wrote:
  Could you point me to a link or show more code?  Not sure exactly
  what
  your trying to accomplish here.

  Joe

  On Dec 31, 9:40 am, vcs jaworskidan...@gmail.com wrote:

  Hello everyone!
  My description:
  I have a field (type div), under which links links are available  
  to
  some country's regions and loaded on button click. When I click on
  loaded data, I mean one of these links, region's districts are
  loaded.
  When I click on one of the districts links, spots (I named
  them-'miejscowosci') are loaded. There is a weird problem, because
  first data is returned correctly by a certain field, while when
  clicking next time, it jumps to the same page and looks like  
  doesn't
  pick up the jquery:
  $('.teryt').click(function(){
                          $('#miejscowosci-wybierz-wyniki').load($
  (this).attr('href'));
                          return false;
                   });


[jQuery] Re: TESTING: replicate event bubbling in tests

2008-12-31 Thread Kean

$('#myScan').click()  does not have event binded to it.
It means fire myScan's click events, think very straightforward in
this case.

On the other hand, when you click on myScan it fires myDiv event
because of bubbling.


On Dec 31, 11:40 am, nachocab nacho...@gmail.com wrote:
 Hi,
 I was wondering how I could replicate event delegation while testing.
 For example:

 div id=myDiv
     scan id=myScanhello/scan
 /div
  $('#myDiv').click(function(e) {
       $this = $(e.target)
       if ( $this.is('scan') )
          $this.toggleClass(selectedScan)

 });

 When I click on the scan in the browser, it works. But if I do this it
 doesn't:
 $('#myScan').click()

 Any help?
 Thanks,

 Nacho


[jQuery] Re: Coda Slider

2008-12-30 Thread Kean

Maybe try jFlow?
http://www.gimiti.com/kltan/wordpress/?p=46

On Dec 30, 6:51 am, simonteu...@googlemail.com
simonteu...@googlemail.com wrote:
 Hello jQuery Community

 I have a question about the Coda Slider.

 How can I create more than one Slider on one Webpage?

 The first works. But the second is just loading.

 Does someone have an idea.

 I would thank you for an answer.

 Simon


[jQuery] Re: Coda Slider

2008-12-30 Thread Kean

Yes, just add the class jFlowPrev to your previous button
and class jFlowNext to your next button.

View the demo source to get the rest.

On Dec 30, 11:02 am, simonteu...@googlemail.com
simonteu...@googlemail.com wrote:
 Hello Kean

 Is jFlow also offering the usage of arrows at the left and right
 sides?

 Nice that you answered so fast.

 I also want to have a ajax live search. I already tried liveSearch by
 andreaslagerkvist.com.

 But it didnt work under windows ie7. Is there also an other option
 with jquery.

 You can look at my project if you like. It's german:www.renchtal.com

 Great Thanks Simon

 On 30 Dez., 18:37, Kean shenan...@gmail.com wrote:

  Maybe try jFlow?http://www.gimiti.com/kltan/wordpress/?p=46

  On Dec 30, 6:51 am, simonteu...@googlemail.com

  simonteu...@googlemail.com wrote:
   Hello jQuery Community

   I have a question about the Coda Slider.

   How can I create more than one Slider on one Webpage?

   The first works. But the second is just loading.

   Does someone have an idea.

   I would thank you for an answer.

   Simon


[jQuery] Re: REFACTOR: contents() with index() or indexOf()

2008-12-30 Thread Kean

$('itemsitemHello/itemitemworld/item!!item
id=my_itemGoodnight moon!/item/items').find(#my_item).each
(function(){
alert(this.innerHTML);
});

Hmm I'd be interested to see how this can be done without using
each

On Dec 30, 12:07 pm, nachocab nacho...@gmail.com wrote:
 Actually that gives an error. It should be:
 var $items = $('itemsitemHello/itemitemworld/item!!item
 id=my_itemGoodnight moon!/item/items');
 for(var i=0; i = $items.children().length; i++){
     if ( $items.contents()[i].id == 'my_item' )
         console.info(i)}

 It also needs to work with $items.contents()[i].className

 On Dec 30, 8:30 pm, nachocab nacho...@gmail.com wrote:

  Hi everyone,
  I'd like to know if there's a way to do this without using a for loop.
  You can just paste this in Firebug:

  var $items = $('itemsitemHello/itemitemworld/item!!item
  id=my_itemGoodnight moon!/item/items');
  for(var i=0; i = $items.children().length; i++){
      if ( $items.contents()[i].id == 'my_item' )
          console.info(i)

  }

  Keep in mind that I need to use contents() to also get the text node
  (!!). I can't seem to use contents().index() properly.

  Thanks,

  Nacho


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-30 Thread Kean

Klaus is right,

Here's an article about closure causing leaks
http://www.javascriptkit.com/javatutors/closuresleak/index.shtml

On Dec 30, 4:38 am, Alexandre Plennevaux aplennev...@gmail.com
wrote:
 Klaus, you got me: frankly i have no real idea what is the purpose
 of enclosure.
 That's abstract art to me. i just read in several places that it's
 good to use it, so i trust my sources, do it and move on. Not that i'm
 proud of it, but, to use a metaphor, one does not need to know the
 internals of a car in order to be able to drive it, although it surely
 is a valuable knowledge if one wants to keep its car in a good state !
 Yet, since the car changes every six months, it's just up to you,
 wheather you're driven by the pure developer's passion or by consumer
 pragmatism.

 On Tue, Dec 30, 2008 at 1:28 PM, Klaus Hartl klaus.ha...@googlemail.com 
 wrote:

  On 30 Dez., 08:45, Alexandre Plennevaux aplennev...@gmail.com
  wrote:
  JavaScript enclosures?

  i think it has to do with encapsulating your code inside a function so
  that all vars are inside the function's scope, so not cluttering the
  global namespace.
  This, to avoid memory leak.

  Are you implying that global variables do leak memory? There are good
  reasons to not clutter the global namespace but I don't believe
  avoiding leaks is one of them.

  Actually you do increase the chance to create leaks in IE if you use
  closures under certain circumstances.

  --Klaus


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-30 Thread Kean

A good reason why closure is used

http://yuiblog.com/blog/2006/06/01/global-domination/



On Dec 30, 1:04 pm, Kean shenan...@gmail.com wrote:
 Klaus is right,

 Here's an article about closure causing 
 leakshttp://www.javascriptkit.com/javatutors/closuresleak/index.shtml

 On Dec 30, 4:38 am, Alexandre Plennevaux aplennev...@gmail.com
 wrote:

  Klaus, you got me: frankly i have no real idea what is the purpose
  of enclosure.
  That's abstract art to me. i just read in several places that it's
  good to use it, so i trust my sources, do it and move on. Not that i'm
  proud of it, but, to use a metaphor, one does not need to know the
  internals of a car in order to be able to drive it, although it surely
  is a valuable knowledge if one wants to keep its car in a good state !
  Yet, since the car changes every six months, it's just up to you,
  wheather you're driven by the pure developer's passion or by consumer
  pragmatism.

  On Tue, Dec 30, 2008 at 1:28 PM, Klaus Hartl klaus.ha...@googlemail.com 
  wrote:

   On 30 Dez., 08:45, Alexandre Plennevaux aplennev...@gmail.com
   wrote:
   JavaScript enclosures?

   i think it has to do with encapsulating your code inside a function so
   that all vars are inside the function's scope, so not cluttering the
   global namespace.
   This, to avoid memory leak.

   Are you implying that global variables do leak memory? There are good
   reasons to not clutter the global namespace but I don't believe
   avoiding leaks is one of them.

   Actually you do increase the chance to create leaks in IE if you use
   closures under certain circumstances.

   --Klaus


[jQuery] Re: REFACTOR: contents() with index() or indexOf()

2008-12-30 Thread Kean

I believe jQuery does not count/iterate textnode. Maybe there's a
function in jQuery but I have no idea.

On Dec 30, 12:52 pm, nachocab nacho...@gmail.com wrote:
 Thank you both,
 The only problem is that the right answer isn't 2, it's 3. I'm
 actually looking for the index of item#my_item inside the contents
 array. children() doesn't take into consideration the !! textnode.

 On Dec 30, 9:43 pm, Ricardo Tomasi ricardob...@gmail.com wrote:

  var $items = $('itemsitemHello/itemitemworld/itemitem
  id=my_itemGoodnight moon!/item/items');
  var $my = $items.find('#my_item');
  console.info( $items.children().index($my) );

  or

  var $items = $('itemsitemHello/itemitemworld/itemitem
  id=my_itemGoodnight moon!/item/items');
  $items.children().each(function(i){
     if ( this.id == 'my_item' ) console.info(i);

  });

  indexOf is a method of the String object, no use in this case.

  On Dec 30, 6:07 pm, nachocab nacho...@gmail.com wrote:

   Actually that gives an error. It should be:
   var $items = $('itemsitemHello/itemitemworld/item!!item
   id=my_itemGoodnight moon!/item/items');
   for(var i=0; i = $items.children().length; i++){
       if ( $items.contents()[i].id == 'my_item' )
           console.info(i)}

   It also needs to work with $items.contents()[i].className

   On Dec 30, 8:30 pm, nachocab nacho...@gmail.com wrote:

Hi everyone,
I'd like to know if there's a way to do this without using a for loop.
You can just paste this in Firebug:

var $items = $('itemsitemHello/itemitemworld/item!!item
id=my_itemGoodnight moon!/item/items');
for(var i=0; i = $items.children().length; i++){
    if ( $items.contents()[i].id == 'my_item' )
        console.info(i)

}

Keep in mind that I need to use contents() to also get the text node
(!!). I can't seem to use contents().index() properly.

Thanks,

Nacho


[jQuery] Interesting on document ready question

2008-12-30 Thread Kean

Is document ready actually an event handler?

Let's say I have

$(function(){

});
$(function(){

});
$(function(){

});
$(function(){

});
$(function(){

});

etc . around 5000 of those.

Will it actually degrade performance like 5000 bind()?
My guess is not much performance penalty, but again, it's a guess.


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-30 Thread Kean

Just a nitpick.

Don't do this
var datascape = new Object();
var datascape2 = new Array();

Instead
var datascape = {};
var datascape2 = [];


On Dec 30, 1:27 pm, Alexandre Plennevaux aplennev...@gmail.com
wrote:
 wair, you're all scarrying me:

 i often do things like this:

 var datascape = new Object();

 datascape.el = $('#datascape');
 datascape.ini = function(){
         datascape.el.click(function(){
           dothis();
           dothat();
         });

 }

 is this pattern causing a potential memory leak problem, because the
 js object is linked to a DOM element?

 On Tue, Dec 30, 2008 at 10:10 PM, Kean shenan...@gmail.com wrote:

  A good reason why closure is used

 http://yuiblog.com/blog/2006/06/01/global-domination/

  On Dec 30, 1:04 pm, Kean shenan...@gmail.com wrote:
  Klaus is right,

  Here's an article about closure causing 
  leakshttp://www.javascriptkit.com/javatutors/closuresleak/index.shtml

  On Dec 30, 4:38 am, Alexandre Plennevaux aplennev...@gmail.com
  wrote:

   Klaus, you got me: frankly i have no real idea what is the purpose
   of enclosure.
   That's abstract art to me. i just read in several places that it's
   good to use it, so i trust my sources, do it and move on. Not that i'm
   proud of it, but, to use a metaphor, one does not need to know the
   internals of a car in order to be able to drive it, although it surely
   is a valuable knowledge if one wants to keep its car in a good state !
   Yet, since the car changes every six months, it's just up to you,
   wheather you're driven by the pure developer's passion or by consumer
   pragmatism.

   On Tue, Dec 30, 2008 at 1:28 PM, Klaus Hartl 
   klaus.ha...@googlemail.com wrote:

On 30 Dez., 08:45, Alexandre Plennevaux aplennev...@gmail.com
wrote:
JavaScript enclosures?

i think it has to do with encapsulating your code inside a function so
that all vars are inside the function's scope, so not cluttering the
global namespace.
This, to avoid memory leak.

Are you implying that global variables do leak memory? There are good
reasons to not clutter the global namespace but I don't believe
avoiding leaks is one of them.

Actually you do increase the chance to create leaks in IE if you use
closures under certain circumstances.

--Klaus


[jQuery] Re: $(document).ready fires before CSS is rendered?

2008-12-30 Thread Kean

I thought I saw an article covering this topic in learningjquery.com
or somewhere else.

Anyone care to show me where the article is?


[jQuery] Re: Interesting on document ready question

2008-12-30 Thread Kean

No, I don't take that as an insult.

I was just wondering how document ready was coded so it really was
just a hypothetical question.

Why do I really need so much on ready?

Also, MorningZ, I will be very active in the jQuery mailing list in
future to learn more js. Perhaps this is not the best starting point
for us.

On Dec 30, 7:23 pm, MorningZ morni...@gmail.com wrote:
 There probably is a better way to do it. 

 Which is what i was getting at..   i hope honest isn't/wasn't
 taken as insulting

 On Dec 30, 10:16 pm, Michael Geary m...@mg.to wrote:

  Come on, MorningZ, there's no need for insults.

  But yes, 5000 of those will be pretty slow - and that's before you even
  execute the code inside those functions. How slow? It's easy to test. The
  ready functions are run in the order that the $() functions are called. So
  simply do this in a test page:

      var t1 = +new Date;
      $(function(){});
      // ... Repeat above line 5000 times
      $(function() {
          var t2 = +new Date;
          alert( (t2-t1)/1000 + ' seconds' );
      });

  You can easily generate that file by hand in a text editor. You don't have
  to do 5000 pastes. Start with 10 of them, copy that block and paste it 10
  times so you have 100, copy *that* block and paste it 10 times so you have
  1000, copy that and five more pastes and you're done.

  Test it in IE6 (!), and if you're on your usual development machine, triple
  the time from the alert to take into account the slower machines that your
  visitors will have (think a slow laptop running on battery). If you don't
  have IE6, try it in IE7 and as a rough guess, multiply your observed time by
  six (triple for the slow machines, double again for IE6).

  Mind if I ask: why do you need 5000 of these? There probably is a better way
  to do it.

  -Mike

   From: MorningZ

   If you've got 5000 of those, it's *seriously* time to
   reconsider your coding techniques.  depending on that
   much JavaScript is just plain old stupid..
   On Dec 30, 8:59 pm, Kean shenan...@gmail.com wrote:
Is document ready actually an event handler?

Let's say I have

$(function(){

});

$(function(){

});

$(function(){

});

$(function(){

});

$(function(){

});

etc . around 5000 of those.

Will it actually degrade performance like 5000 bind()?
My guess is not much performance penalty, but again, it's a guess.


[jQuery] Re: Fastest way to clear child elements from a div

2008-12-30 Thread Kean

Sounds like your nodes have to much element binded to them.


On Dec 30, 1:00 pm, Adam Guichard amguich...@gmail.com wrote:
 It ran in 5ms, but its my understanding if I use the method your
 suggesting I'll be leaking memory.  If I just set the innerhtml = ,
 I think the dom element's children aren't disposed.  They just sit
 around chewing up memory, so I don't think I can use the method your
 suggesting.

 On Dec 30, 2:42 pm, MorningZ morni...@gmail.com wrote:

  just for laughs...see of

  document.getElementById(ID of Div Tag).innerHTML = ;

  is anything of an improvement

  On Dec 30, 3:02 pm, Adam Guichard amguich...@gmail.com wrote:

   I'm using jTemplates to create a client grid, but I'm having trouble
   with load times.  When I'm paging through the grid jTemplates is
   taking 4+ seconds to clear the grid and 2+ seconds to load it.  I've
   got some work to do to make the loading time go down, but I'm worried
   about the clearing time.  I've tried a few different methods, but
   nothing seems to be really fast.  I'd like to be able to clear the div
   in less than a second.  Here's what I've tried:

   $(selector).empty() and $(selector).html('') both took between  3-4
   seconds

   Does anyone know of a faster way to empty the child elements of a div?


[jQuery] Re: Fastest way to clear child elements from a div

2008-12-30 Thread Kean

Oops I mean event.

On Dec 30, 8:11 pm, Kean shenan...@gmail.com wrote:
 Sounds like your nodes have to much element binded to them.

 On Dec 30, 1:00 pm, Adam Guichard amguich...@gmail.com wrote:

  It ran in 5ms, but its my understanding if I use the method your
  suggesting I'll be leaking memory.  If I just set the innerhtml = ,
  I think the dom element's children aren't disposed.  They just sit
  around chewing up memory, so I don't think I can use the method your
  suggesting.

  On Dec 30, 2:42 pm, MorningZ morni...@gmail.com wrote:

   just for laughs...see of

   document.getElementById(ID of Div Tag).innerHTML = ;

   is anything of an improvement

   On Dec 30, 3:02 pm, Adam Guichard amguich...@gmail.com wrote:

I'm using jTemplates to create a client grid, but I'm having trouble
with load times.  When I'm paging through the grid jTemplates is
taking 4+ seconds to clear the grid and 2+ seconds to load it.  I've
got some work to do to make the loading time go down, but I'm worried
about the clearing time.  I've tried a few different methods, but
nothing seems to be really fast.  I'd like to be able to clear the div
in less than a second.  Here's what I've tried:

$(selector).empty() and $(selector).html('') both took between  3-4
seconds

Does anyone know of a faster way to empty the child elements of a div?


[jQuery] Re: Interesting on document ready question

2008-12-30 Thread Kean

Hi Ricardo,

Sweet, that's what I was expecting for an answer.


[jQuery] Re: Fastest way to clear child elements from a div

2008-12-30 Thread Kean

If I read the jQuery source code right, it seems that .html() does not
use this replaceHTML method even in 1.3b1


On Dec 30, 8:21 pm, Ricardo Tomasi ricardob...@gmail.com wrote:
 There is a long discussion about better 'innerHTML' methods, see here
 (check the comments also):

 http://blog.stevenlevithan.com/archives/faster-than-innerhtmlhttp://ajaxian.com/archives/replacehtml-for-when-innerhtml-dogs-you-down

 On Dec 30, 7:00 pm, Adam Guichard amguich...@gmail.com wrote:

  It ran in 5ms, but its my understanding if I use the method your
  suggesting I'll be leaking memory.  If I just set the innerhtml = ,
  I think the dom element's children aren't disposed.  They just sit
  around chewing up memory, so I don't think I can use the method your
  suggesting.

  On Dec 30, 2:42 pm, MorningZ morni...@gmail.com wrote:

   just for laughs...see of

   document.getElementById(ID of Div Tag).innerHTML = ;

   is anything of an improvement

   On Dec 30, 3:02 pm, Adam Guichard amguich...@gmail.com wrote:

I'm using jTemplates to create a client grid, but I'm having trouble
with load times.  When I'm paging through the grid jTemplates is
taking 4+ seconds to clear the grid and 2+ seconds to load it.  I've
got some work to do to make the loading time go down, but I'm worried
about the clearing time.  I've tried a few different methods, but
nothing seems to be really fast.  I'd like to be able to clear the div
in less than a second.  Here's what I've tried:

$(selector).empty() and $(selector).html('') both took between  3-4
seconds

Does anyone know of a faster way to empty the child elements of a div?


[jQuery] Re: Please help me on a .lt method

2008-12-30 Thread Kean

Make a demo page or a html page.

Some common mistakes

1. Did you include jQuery?
2. Did you write something like
var $table =$('table') before using  $table.find() ?


On Dec 30, 7:30 pm, Samuel Wu samuel.yh...@gmail.com wrote:
 Hi, everyone

 I started writing jquery from last week with the help from a very good
 book Learning Jquery.

 I met a problem when reading the book, which has the script:

 code
 $table.find('tbody tr').show()
 .lt(2)
 .hide()
 .end()
 .gt(5)
 .end();
 /code

 Where 2 and 5 are different from the book, but I think it has no
 effect to the problem.

 I haven't met a lt or gt method before, I can only write
 code
     $table.find('tbody tr:lt(2)').hide();
     $table.find('tbody tr:gt(5)').hide();
 /code

 I tried the author's code, which didn't work on my browser. the
 browser said
 TypeError: $(table).find(tbody tr).show().lt is not a function

 I also tried this way:
 code
 var $trow=$table.find('tbody tr')
 $trow.lt(2).hide()
 code

 the problem still exists there.

 My question is:
 Is lt or gt a method used as a  selector ?
 If I want to implement the chain actions like the first code, how
 could I do that?

 Any help is appreciated. thanks very much. Happy new year.


[jQuery] Re: Interesting on document ready question

2008-12-30 Thread Kean

 Why do I really need so much on ready?
 Yes! That's what we're all wondering! Don't keep us in suspense. :-)

When you work with a bunch of morons in a company that uses them
throughout the site and when the js are packaged will lead to
unnecessary performance loss.


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-30 Thread Kean

As for JS, saving bytes is totally a good thing.

On Dec 30, 10:53 pm, Alexandre Plennevaux aplennev...@gmail.com
wrote:
 why? It's just a shorthand, isn't it ? does it affect the computer
 resources in any manner ?

 On Wed, Dec 31, 2008 at 3:12 AM, Kean shenan...@gmail.com wrote:

  Just a nitpick.

  Don't do this
  var datascape = new Object();
  var datascape2 = new Array();

  Instead
  var datascape = {};
  var datascape2 = [];

  On Dec 30, 1:27 pm, Alexandre Plennevaux aplennev...@gmail.com
  wrote:
  wair, you're all scarrying me:

  i often do things like this:

  var datascape = new Object();

  datascape.el = $('#datascape');
  datascape.ini = function(){
          datascape.el.click(function(){
            dothis();
            dothat();
          });

  }

  is this pattern causing a potential memory leak problem, because the
  js object is linked to a DOM element?

  On Tue, Dec 30, 2008 at 10:10 PM, Kean shenan...@gmail.com wrote:

   A good reason why closure is used

  http://yuiblog.com/blog/2006/06/01/global-domination/

   On Dec 30, 1:04 pm, Kean shenan...@gmail.com wrote:
   Klaus is right,

   Here's an article about closure causing 
   leakshttp://www.javascriptkit.com/javatutors/closuresleak/index.shtml

   On Dec 30, 4:38 am, Alexandre Plennevaux aplennev...@gmail.com
   wrote:

Klaus, you got me: frankly i have no real idea what is the purpose
of enclosure.
That's abstract art to me. i just read in several places that it's
good to use it, so i trust my sources, do it and move on. Not that i'm
proud of it, but, to use a metaphor, one does not need to know the
internals of a car in order to be able to drive it, although it surely
is a valuable knowledge if one wants to keep its car in a good state !
Yet, since the car changes every six months, it's just up to you,
wheather you're driven by the pure developer's passion or by consumer
pragmatism.

On Tue, Dec 30, 2008 at 1:28 PM, Klaus Hartl 
klaus.ha...@googlemail.com wrote:

 On 30 Dez., 08:45, Alexandre Plennevaux aplennev...@gmail.com
 wrote:
 JavaScript enclosures?

 i think it has to do with encapsulating your code inside a 
 function so
 that all vars are inside the function's scope, so not cluttering 
 the
 global namespace.
 This, to avoid memory leak.

 Are you implying that global variables do leak memory? There are 
 good
 reasons to not clutter the global namespace but I don't believe
 avoiding leaks is one of them.

 Actually you do increase the chance to create leaks in IE if you use
 closures under certain circumstances.

 --Klaus


[jQuery] Re: Interesting on document ready question

2008-12-30 Thread Kean

5000 is just an exaggeration, it's probably in the realm of 20

On Dec 30, 10:42 pm, Kean shenan...@gmail.com wrote:
  Why do I really need so much on ready?
  Yes! That's what we're all wondering! Don't keep us in suspense. :-)

 When you work with a bunch of morons in a company that uses them
 throughout the site and when the js are packaged will lead to
 unnecessary performance loss.


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-30 Thread Kean

Alexandre,

Another word of caution. Do choose your labels carefully. Avoid
keywords.
Adding quotes to keyword labels ensure compatibility with YUI
compressor.

var a = {
// new without quotes produce error in ie
new: function() {
alert(new);
},
// class without quotes produce error in ie
class: function() {
alert(class);
},
// YUI compressor won't compress if you have no quotes on keywords
float: function() {
alert(float);
},
int: function(){
alert(int);
}
}

a.new(); // still fails in ie
a.class(); // still fails in ie
a.float();
a.int();


[jQuery] Re: define and invoke class inside $(document).ready

2008-12-29 Thread Kean

Looks fine to me.

Is myClass used in other places (ie outside of your document ready)?
If so, you have to define it outside of document ready or do this

window.myClass = function() {
  this.imagesHolder = null;
}


On Dec 29, 7:09 pm, bob xoxeo...@gmail.com wrote:
 Is that a correct way to create class utilizing jQuery?

 var myClass = null;

 $(document).ready(function(){
         function MyClass(){
                 this.imagesHolder = null;
         }

         MyClass.prototype.init = function (){
                 this.imagesHolder = jQuery(#imgs);
         }

       myClass = new MyClass();

 });


[jQuery] Re: getting the id of a clicked object

2008-12-29 Thread Kean

Try this then

jQuery(function($){
  $(a[class=clicker]).click(function() {
alert(this.id);
  });
});


On Dec 29, 4:27 pm, buttman nbvf...@gmail.com wrote:
 That doesn't work. When I do

 alert(this.id)

 in that function, nothing comes up. Additionally, alert(this) just
 displays the url.

 On Dec 29, 7:16 pm, Mike Alsup mal...@gmail.com wrote:

   I have a bunch of anchors that look like this:
   
a href= class=clicker id=click_1click here/a
a href= class=clicker id=click_2click here/a
a href= class=clicker id=click_3click here/a
   #

   The my jquery code looks like this:

   #
   $(a[class=clicker]).click(function() {
       do_something(id);})

   #

   do_something() needs the id of the button clicked. So if I clicked on
   the second anchor, I need click_2 to be passed to do_something().
   How di I do this in jQuery?

  $(a[class=clicker]).click(function() {
      var id = this.id;
      do_something(id);

  });


[jQuery] Re: getting the id of a clicked object

2008-12-29 Thread Kean

This is even better.

jQuery(function($){
   $(a.clicker).click(function() {
 alert(this.id);
   });
});

On Dec 29, 7:21 pm, Kean shenan...@gmail.com wrote:
 Try this then

 jQuery(function($){
   $(a[class=clicker]).click(function() {
     alert(this.id);
   });

 });

 On Dec 29, 4:27 pm, buttman nbvf...@gmail.com wrote:

  That doesn't work. When I do

  alert(this.id)

  in that function, nothing comes up. Additionally, alert(this) just
  displays the url.

  On Dec 29, 7:16 pm, Mike Alsup mal...@gmail.com wrote:

I have a bunch of anchors that look like this:

 a href= class=clicker id=click_1click here/a
 a href= class=clicker id=click_2click here/a
 a href= class=clicker id=click_3click here/a
#

The my jquery code looks like this:

#
$(a[class=clicker]).click(function() {
    do_something(id);})

#

do_something() needs the id of the button clicked. So if I clicked on
the second anchor, I need click_2 to be passed to do_something().
How di I do this in jQuery?

   $(a[class=clicker]).click(function() {
       var id = this.id;
       do_something(id);

   });


[jQuery] Re: Event registered for a class does not work with all members of class

2008-12-29 Thread Kean

Yea, use clone(true) to copy the events.

If you are using jQuery 1.3 beta you can try to use

$(selector).live('event', function(){

});

live is like bind just that new nodes added to DOM will inherit the
event.

Well, this is a trick call event delegation.


On Dec 29, 2:40 pm, Ricardo Tomasi ricardob...@gmail.com wrote:
 Didn't look at the source, but have you tried $(element).clone(true) ?
 That sets 'deep copying' and should copy all the event handlers with
 it.

 On Dec 29, 11:33 am, nikla...@googlemail.com

 nikla...@googlemail.com wrote:
  Hello,

  I don't know wether it is the right place for this question but I am
  going to ask it anyway. I used jquery on my site and I registered a
  function on all of the nodes of a certain class like this:

  $('.up').click(function(){
     /* do stuff*/

  });

  The interesting thing about it is that this assignment of the function
  to the event only appears to work with some of the elements. I have a
  div container on the left containing elements classed .up. If .up
  is clicked I then go, clone the element and put it into what I call
  the shopping trolley on the right. Now since I have cloned the node
  which contains a .up classed element I would think that after
  cloning the clone does inherit the event assignment. But oddly it does
  not seem to. And it gets even more obsurd. If I then go and try to
  reassign the event to the copied node, it still does not call the
  assigned function when .up on the right side is clicked.

  You can have a look at the source 
  athttp://niklas.bplaced.net/dev/php/gallery.php

  Your help is very much appreciated.

  Greetings Niklas


[jQuery] Re: Plugin that highlights divs

2008-12-29 Thread Kean

There's a plugin call jFade that will fade/highlight colors
http://www.gimiti.com/kltan/wordpress/?p=43


On Dec 29, 1:22 pm, Tipem ti...@thedailyneopets.com wrote:
 Hi,

 I've seen a Jquery plugin before that triggers an event which pulsates
 or highlights a div of your choice.  I've also seen the plugin
 scroll the page to the correct div.  Does anybody know what this
 plugin is called?  I'd really like to use it...

 I've been searching the plugins directory for a while, but can't seem
 to find it!

 Thanks


[jQuery] Re: define and invoke class inside $(document).ready

2008-12-29 Thread Kean

You have to get the execution order right.

this is just a declaration, to let javascript know that this function
exists

  MyClass.prototype.init = function (){
this.imagesHolder = jQuery(#imgs);
}


jQuery(#imgs) is not executed until you do something like this.


var a = new myclass()

a.init(); // put this inside dom ready


On Dec 29, 8:14 pm, bob xoxeo...@gmail.com wrote:
 Yep, I intend to use myClass outside of document ready.

 I thought that in order to use jQuery as follows
 this.imagesHolder = jQuery(#imgs);
 inside of MyClass I would have to enclose it inside
 $(document).ready(function(){...
 so that DOM is ready before invoking MyClass.
 Is my assumption wrong?


[jQuery] Re: getting the id of a clicked object

2008-12-29 Thread Kean

I'd be interested to see your html too.

Ok another try

jQuery(function($){
   $(a.clicker).click(function() {
 alert(this.id);
 return false;
   });

});

On Dec 29, 7:54 pm, buttman nbvf...@gmail.com wrote:
 Still not working... I still get a blank popup window :( This is all
 supposed to be inside the document.ready() thing, right?

 On Dec 29, 10:22 pm, Kean shenan...@gmail.com wrote:

  This is even better.

  jQuery(function($){
     $(a.clicker).click(function() {
       alert(this.id);
     });

  });

  On Dec 29, 7:21 pm, Kean shenan...@gmail.com wrote:

   Try this then

   jQuery(function($){
     $(a[class=clicker]).click(function() {
       alert(this.id);
     });

   });

   On Dec 29, 4:27 pm, buttman nbvf...@gmail.com wrote:

That doesn't work. When I do

alert(this.id)

in that function, nothing comes up. Additionally, alert(this) just
displays the url.

On Dec 29, 7:16 pm, Mike Alsup mal...@gmail.com wrote:

  I have a bunch of anchors that look like this:
  
   a href= class=clicker id=click_1click here/a
   a href= class=clicker id=click_2click here/a
   a href= class=clicker id=click_3click here/a
  #

  The my jquery code looks like this:

  #
  $(a[class=clicker]).click(function() {
      do_something(id);})

  #

  do_something() needs the id of the button clicked. So if I clicked 
  on
  the second anchor, I need click_2 to be passed to do_something().
  How di I do this in jQuery?

 $(a[class=clicker]).click(function() {
     var id = this.id;
     do_something(id);

 });


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-29 Thread Kean

Here's a few answers.


2. XmlHTTPrequest object, returns XHR request as obj or string, YUI
callback augments object, jQuery callback augments string

4. http://www.json.org/

5. block / inline

6.
assume allLayer is array of layer1 and layer2
YAHOO.util.Dom.setStyle(allLayer,  opacity, 66%);
YAHOO.util.Dom.setStyle(allLayer[0],  backgroundColor, #000);




On Dec 29, 7:47 pm, Angel Marquez angel.marq...@gmail.com wrote:
 *(required) Q: *Describe the difference in result of the JavaScript DOM
 methods getElementById and getElementsByClassName.

 *2. (required) *Given this JavaScript statement:
 *
 **       objXHR.open('GET',**' HYPERLINK http://http://myURL.com',true**
 );**
 *
         a.* Q:* What, probably, is the type of the object named objXHR?

         b.* Q: *What is the purpose of each of the parameters being passed
 to the open method?

 *Q: *If an absolute URL is passed in the second argument, what kind of
 restriction *usually *applies?

 *   3. (required) *How would you *(a) *declare and then *(b) *instantiate a
 JavaScript class to describe a Square object, taking one argument in its
 constructor?  The instance of a Square should have sides 4 units in length.
 *( c )*What properties might a Square object have and how would they be
 coded?

         *a.* declare: function Square(numericSideArgument) {
                             ... (some other stuff)
                             }
         *b.* use: var mySquare = new Square(4);
         *c.* methods: *perimeter*, coded as this.perimeter =
 numericSideArgument * 4;
                               *area*, coded as this.area =
 numericSideArgument ^ 2; (squared, i.e. width * height)
         So, the whole definition of Square would be:

                             function Square(numericSideArgument) {

                            this.perimeter = numericSideArgument * 4;
                             this.area = numericSideArgument ^ 2;
                             return this;

                            }

                             So, *Q: *mySquare.perimeter would equal?

  *Q: *mySquare.area would equal *?*

 *  4.* *(desired) *An object called auto has an id attribute with value
 of taurus and a color attribute with value blue.  Additionally, it has
 a child object radio, which contains an array knob which contains three
 items with names and shapes:

 name: power, shape: round

 name: tune, shape: oval

 name: scan, shape: square

 *Q: *What does the acronym JSON stand for?
 *Q: *What does this object look like in JSON?

 *   BONUS 5.* *(CSS-related)* Describe the difference between a DIV
 element versus a SPAN.

 **

 *   BONUS 6.* *(Advanced JavaScript and YUI)* If I have a JavaScript
 collection object YAHOO.util.Dom with a member method setStyle that
 takes three arguments

 an array of element id's

 a css property name, and

 a single float value,

 ...*Q: *how would I write the *single *line of JavaScript that sets the
 transparency of DIV's layer1 and layer2 to 66%?

         *Q:* How would I write the single line of JavaScript that sets the
 background color of only DIV layer1 to hexadecimal black?

         *Q: *If there was another method which DID take a single-value,
 non-array, in that first argument, in object-oriented terminology, the
 method would be said to be what?

         *Q: *Does JavaScript support overloading?

         *BONUS 7:* *(Super-impressive)* *Q: *Can you summarize the
 definition of JavaScript enclosures?


[jQuery] Re: getting the id of a clicked object

2008-12-29 Thread Kean

Richardo,

LOL


[jQuery] Re: HELP: Screening questions for JavaScript developer candidates:

2008-12-29 Thread Kean

Concur with Michael, that's why I'd answered the obvious ones.


[jQuery] Re: Merry Xmass

2008-12-24 Thread Kean

Merry xmas to you too.

On Dec 24, 5:20 am, Lukas Polak polak.luka...@gmail.com wrote:
 Hi everybody,

 I don't want you interrupt, but I don't know if you already notice that
 today is 24th December so at least today you shoold stop working and
 relax :)  Merry Christmas to all of you :)

 elf from Slovakia


[jQuery] Re: How do I make a partial textarea autocomplete?

2008-12-24 Thread Kean

Interesting idea, but, owing to your idea, I am more interested in
knowing if there's a way to determine current active keyboard cursor
offset in document.


On Dec 24, 1:26 am, Sam Unplugged guptasamee...@gmail.com wrote:
 Hello,

 Is there an example of partial autocomplete? By 'partial' I mean, only
 a part of textarea gets suggestions.

 Users in my project are supposed to start a message in a textarea with
 'Dear UserName'

 I want to make this UserName part either clickable like in Office
 documents custom fields, and when a user is editing this part I want
 to show a list of options (usernames from a database).

 I can work out the backend, but I have no clue where to begin to make
 such a textarea. Please help.

 Thanks a ton.

 Sam


[jQuery] Re: problem with fadein() and image sizes in IE

2008-12-24 Thread Kean

I hope you are using jQuery 1.2.6

Try these

$(myImage).width(width);
$(myImage).height(width/0.75);



On Dec 23, 11:43 pm, Paddy Joy paddy...@gmail.com wrote:
 Hope someone can help out here, I'm new to jquery and can't figure out
 what I have done wrong here.

 The following code works ok in FF and IE, it is a function that
 appends an image to a div and sets the width/height of that image.

 function showImage(src,divid,width)
 {
 var myImage = new Image();
 $(myImage).load(function()
                         {
                            $(divid).append(this)
                         });
 $(myImage).attr(src, src);
 $(myImage).attr(width, width);
 $(myImage).attr(height, width/0.75);

 }

 I have modified the code so that the image fades in. This works fine
 in FF but in IE the image displays at its original dimensions and not
 at the dimensions I have set in the code.

 function showImage(src,divid,width)
 {
 var myImage = new Image();
 $(myImage).load(function()
                         {
                            $(this).hide();
                            $(divid).append(this)
                                   $(this).fadeIn(fast);
                         });
 $(myImage).attr(src, src);
 $(myImage).attr(width, width);
 $(myImage).attr(height, width/0.75);

 }

 Anyone any ideas?

 Paddy


[jQuery] Re: display:none not working in IE

2008-12-24 Thread Kean

You might have to look at your CSS if you have declared something like
display: block !important;

On Dec 24, 12:34 am, ben.hollis ben.hol...@gmail.com wrote:
 Guess you'll have to provide a more detailed example of the problem
 you're experiencing then.

 On Dec 24, 12:05 am, Namrata Vagyani vagyaninamr...@gmail.com
 wrote:

  This aslo not working :(

  On Wed, Dec 24, 2008 at 12:26 PM, ben.hollis ben.hol...@gmail.com wrote:

   That should work, but try $(this).hide() instead. It does the same
   thing.

   On Dec 23, 10:29 pm, Debby vagyaninamr...@gmail.com wrote:
Hi,

css({'display':'none'}) is not working in IE.
I am trying this in loop, for perticular condition i need to display
none for this case,
so i tried with this
$(this).css({'display':'none'});
but its working fine Mozilla but not in IE

Please do needful.


[jQuery] Re: Objected Expected $ Conflict?

2008-12-22 Thread Kean

Also for ids, it's better to write

$('#item' + slideNum)

than

$('#carousel #item' + slideNum).

On Dec 22, 6:19 am, MorningZ morni...@gmail.com wrote:
 Try replacing $ with jQuery and see if you get the same error
 (this will tell you if it's a conflict or something else)

 but it makes no sense that $ would work on one browser but not
 another, regardless, doing the above will help diagnose

 On Dec 22, 3:17 am, Pete peterberna...@gmail.com wrote:

  I'm trying to build a simple news carousel, click a tab and the
  corresponding div shows. My Code works in FF, Chrome, Opera and Safari
  but no luck in IE 6 or 7. I think it has something to do with $,
  because IE7 is saying there is an Object Expected at that char
  position.

  Any help is appreciated, my code is below.

  script src=js/jquery-1.2.6.min.js type=text/javascript/script
  script type=text/javascript
  !--

  current = 1;
  function showSlide(slideNum)
  {
             if (slideNum != current){
                  $('#carousel #item' + current).fadeOut(slow).addClass
  (hidden);
                  $('#carousel #item' + slideNum).fadeIn(slow).removeClass
  (hidden);
                  current = slideNum;
                   }
             }

  //--
  /script


[jQuery] Re: attributes setting appending rather than clearing

2008-12-22 Thread Kean

Not sure the best way to do this, but this might work

jQuery(function(){
  var anotherFunction() {
  // your thing
  }
  var myFunction() {
// do something

$(this).bind('click', anotherFunction);
$(this).unbind('click', myFunction);
  }
  $('a').bind('click', myFunction);
});


On Dec 22, 5:59 am, alextait alext...@gmail.com wrote:
 I am setting the click attribute of an anchor tag using query on the
 document ready event.

 Once the user has clicked on this link I am attempting to change the
 click event to call another method than the one initialy setup.
 Instead of replacing the old method is simply appends the new method
 so that both methods are called .

 any help would be great !

 thanks


[jQuery] Re: Smarter way to write this repetitive code?

2008-12-22 Thread Kean

dbzz, IMO, your code still add a listener to each of the .headline

var txt = $('.article-text');
var $hl = $('.headline');

$hl.click(function(e) {
$(txt[$hl.index(e.target)]).fadeIn();
});

I highly doubt that this code will run faster than the one using each.

On Dec 22, 9:20 am, dbzz j...@briskey.net wrote:
 and if you have _really_ a lot of elements...
 instead of a listener on each, just use one -

 var $hl = $('.headline');
 $hl.click(function(e) {
         $('.article-text').eq( $hl.index(e.target) ).fadeIn();

 });

 On Dec 21, 5:57 am, Kean shenan...@gmail.com wrote:

  Some performance improvement, especially if you have a lot of
  elements.

  var txt = $('.article-text');

  $('.headline').each(function(i) {
    $(this).click(function() {
      $(txt[i]).fadeIn();
    })

  });


[jQuery] Re: change element attribute, then have jquery act on that change?

2008-12-22 Thread Kean

Livequery and other event delegation techniques are cool, but, in a
matter of simplicity

pschwei1 , why don't you try the jQuery toggle event? I think it will
definitely work for this case.

http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...


On Dec 22, 2:34 pm, Dave Methvin dave.meth...@gmail.com wrote:
  I'm using filters to find if an li's text matches a certain value,
  and then changing the value if it does. This works fine.  However, if
  I then use my selectors to check for the new value, jquery does not
  seem to pick it up, making me wonder if perhaps the selectors only
  work for values coded into the actual html, not generated by jquery.

 Are you executing that block of code each time you change the content?
 The selectors work for the content that exists at the time you execute
 it. So for this:

 $(li.dnt:contains('Donate')).click(function(){
    ...

 });

 The click handler is attached for all li.dnt elements that contain
 Donate at that point in time. If you later add the text Donate to
 a li.dnt element that didn't previously have it, jQuery is not
 constantly checking the document to determine that you  have done
 this.

 If you really want that behavior of having jQuery constantly check for
 updates and attaching handlers, check out the livequery plugin.


[jQuery] Re: How can I generalize this code for all values?

2008-12-22 Thread Kean

try this, it accounts for checking all the required fields to see if
they are blank and disable

jQuery(function(){

// all the required text fields
var $required = $('input.required:text');

// function checks for blank input
var isBlank = function(str) {
return $.trim(str).length==0
}

// function checks if other required fields are blank
var checkAllRequired = function () {
var allFilled = true;
$required.each(function() {
if (isBlank(this.value))
allFilled = false;
});
return allFilled;
}

// initially disable or enable the submit button
$(#submit).attr('disabled', checkAllRequired() ? null :
disabled);


// same as $required each blur
$required.blur(function() {
// checks if current field is blank
if (isBlank(this.value))
$(# + this.id + _error).fadeIn(500);
else
$(# + this.id + _error).fadeOut(500);

$(#submit).attr('disabled', checkAllRequired() ? null :
disabled);

 });

});

On Dec 22, 3:54 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 Ok...after a lot of experimentation, I've got a solution
 that's working to the point that I've attempted to implement it.

 Here's the code:

 $(document).ready(function() {

      $('input:text.required').each(function() {
           $(this).blur(function() {
                var val = (this.value.length);
                     if (val == 0)
                          { $(# + this.id + _error).fadeIn(500);
                            $('#submit').attr('disabled', 'disabled'); }
                     else
                          { $(# + this.id + _error).fadeOut(500);
                            $('#submit').removeAttr('disabled'); };

      $('input:text.required').each(function() {
           var val = (this.value.length);
                if (val == 0)
                     { $('#submit').attr('disabled', 'disabled'); }
      });

           });
      });

 });

 This code allows for the following:

 - on blur of any text input with class 'required' the length is checked
 - if the length of the required field is  0, then the error message is shown
   and the submit button for the form is disabled

 - the second half of the code checks all the text inputs with class 'required'
 - if the length of any of the required text fields is 0, then the submit 
 button is disabled

 What I need to do now:

 - Allow for other type of inputs to be checked on blur, etc., such as selects
   (Later, I'll add other types of validation, such as numeric, etc.)

 Question:

 - How do I modify ('input:text.required') to accommodate other types of 
 required inputs?
 - I tried ('input:text.required, input:select.required') and
           ('input:text.required', 'input:select.required') but that didn't 
 work

 Clues or hints?

 Thanks,

 Rick

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
  Behalf Of MorningZ
  Sent: Monday, December 22, 2008 2:40 PM
  To: jQuery (English)
  Subject: [jQuery] Re: How can I generalize this code for all values?

  Try this change

  $(#submit).attr('disabled', (val == ) ? disabled : null);

  If that doesn't work, then perhaps:

  if (val == ) {
        $(# + this.id + _error).fadeIn(500);
        $(#submit).attr(disabled, disabled);
  }
  else {
        $(# + this.id + _error).fadeOut(500);
        $(#submit).removeAttr(disabled);
  }

  On Dec 22, 2:21 pm, Rick Faircloth r...@whitestonemedia.com wrote:
   I see in your example code that you're still using a hard-coded name
   for the input.  I'd like it completely generalized for all variables.

   I'm working towards creating code for categories of input types:  text,
   radio, checkbox, and textarea, etc.

   I modified your example, and all seems to be working well with the code
   below, except that the submit button is becoming enabled even when there
   is an error message showing.  I don't understand the last line enough
   to even tinker with that...suggestions?

   Thanks, Rick

   Here's the new code:

   $(document).ready(function() {

        $(inp...@type='text']).each(function() {

             $(this).blur(function() {
                  var val = $.trim(this.value);

                  if (val == )
                     { $(# + this.id + _error).fadeIn(500); }
                  else
                     { $(# + this.id + _error).fadeOut(500); }
                       $(#submit).attr('disabled', (val == ) ? 
   disabled : );
             });
        });

   });
-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
Behalf Of MorningZ
Sent: Monday, December 22, 2008 1:44 PM
To: jQuery (English)
Subject: [jQuery] Re: How 

[jQuery] Re: How can I generalize this code for all values?

2008-12-22 Thread Kean

var checkAllRequired = function () {
var allFilled = true;
$required.each(function() {
if (isBlank(this.value))
allFilled = false;
});
return allFilled;
}

can be optimized to

   var checkAllRequired = function () {
for (var i=0; i$required.length; i++)
 if (isBlank($required[i].value))
   return false;
return true;
}


On Dec 22, 5:26 pm, Kean shenan...@gmail.com wrote:
 try this, it accounts for checking all the required fields to see if
 they are blank and disable

 jQuery(function(){

         // all the required text fields
         var $required = $('input.required:text');

         // function checks for blank input
         var isBlank = function(str) {
                 return $.trim(str).length==0
         }

         // function checks if other required fields are blank
         var checkAllRequired = function () {
                 var allFilled = true;
                 $required.each(function() {
                         if (isBlank(this.value))
                                 allFilled = false;
                 });
                 return allFilled;
         }

         // initially disable or enable the submit button
         $(#submit).attr('disabled', checkAllRequired() ? null :
 disabled);

         // same as $required each blur
         $required.blur(function() {
                 // checks if current field is blank
                 if (isBlank(this.value))
                         $(# + this.id + _error).fadeIn(500);
                 else
                         $(# + this.id + _error).fadeOut(500);

                 $(#submit).attr('disabled', checkAllRequired() ? null :
 disabled);

      });

 });

 On Dec 22, 3:54 pm, Rick Faircloth r...@whitestonemedia.com wrote:

  Ok...after a lot of experimentation, I've got a solution
  that's working to the point that I've attempted to implement it.

  Here's the code:

  $(document).ready(function() {

       $('input:text.required').each(function() {
            $(this).blur(function() {
                 var val = (this.value.length);
                      if (val == 0)
                           { $(# + this.id + _error).fadeIn(500);
                             $('#submit').attr('disabled', 'disabled'); }
                      else
                           { $(# + this.id + _error).fadeOut(500);
                             $('#submit').removeAttr('disabled'); };

       $('input:text.required').each(function() {
            var val = (this.value.length);
                 if (val == 0)
                      { $('#submit').attr('disabled', 'disabled'); }
       });

            });
       });

  });

  This code allows for the following:

  - on blur of any text input with class 'required' the length is checked
  - if the length of the required field is  0, then the error message is 
  shown
    and the submit button for the form is disabled

  - the second half of the code checks all the text inputs with class 
  'required'
  - if the length of any of the required text fields is 0, then the submit 
  button is disabled

  What I need to do now:

  - Allow for other type of inputs to be checked on blur, etc., such as 
  selects
    (Later, I'll add other types of validation, such as numeric, etc.)

  Question:

  - How do I modify ('input:text.required') to accommodate other types of 
  required inputs?
  - I tried ('input:text.required, input:select.required') and
            ('input:text.required', 'input:select.required') but that didn't 
  work

  Clues or hints?

  Thanks,

  Rick

   -Original Message-
   From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
   Behalf Of MorningZ
   Sent: Monday, December 22, 2008 2:40 PM
   To: jQuery (English)
   Subject: [jQuery] Re: How can I generalize this code for all values?

   Try this change

   $(#submit).attr('disabled', (val == ) ? disabled : null);

   If that doesn't work, then perhaps:

   if (val == ) {
         $(# + this.id + _error).fadeIn(500);
         $(#submit).attr(disabled, disabled);
   }
   else {
         $(# + this.id + _error).fadeOut(500);
         $(#submit).removeAttr(disabled);
   }

   On Dec 22, 2:21 pm, Rick Faircloth r...@whitestonemedia.com wrote:
I see in your example code that you're still using a hard-coded name
for the input.  I'd like it completely generalized for all variables.

I'm working towards creating code for categories of input types:  text,
radio, checkbox, and textarea, etc.

I modified your example, and all seems to be working well with the code
below, except that the submit button is becoming enabled even when there
is an error message showing.  I don't understand the last line enough
to even tinker with that...suggestions?

Thanks, Rick

[jQuery] Re: Smarter way to write this repetitive code?

2008-12-21 Thread Kean

Some performance improvement, especially if you have a lot of
elements.

var txt = $('.article-text');

$('.headline').each(function(i) {
  $(this).click(function() {
$(txt[i]).fadeIn();
  })
});

On Dec 20, 10:33 pm, chriscoyier chriscoy...@gmail.com wrote:
 Perfect!

 Thanks Ryura =)

 On Dec 20, 7:21 pm, Ryura yoyobo...@gmail.com wrote:

  $('.headline').each(function(i) {
          $(this).click(function() {
                  $('.article-text:eq('+i+')').fadeIn();
          })

  })


[jQuery] Re: Blank input value testing

2008-12-21 Thread Kean

Well blank() was not created in jQuery.

You can create a new function for jQuery like this.

(function($){
  $.fn.blank = function(){
return $.trim(this[0]).length == 0;
  }
})(jQuery)

input id=one value=sadf /
input id=two value=   /

$('#one').blank(); // return false
$('#two').blank(); // return true

haven't tested the code but should be pointing you to the right
direction.

Great thing is that jQuery allows you to extend it as you see fit.
On Dec 21, 12:40 am, Lay András lays...@gmail.com wrote:
 Hello!

 Is there any way in jQuery to test if a input value is blank? I mean
 similar like:

 if ($F('szoveg').blank()) {
    ...

 }

 in prototype. With jQuery now i'm using this:

 if ($('#szoveg').val()=='') {
    ...

 }

 but this not test if a input contains only whitespaces.

 Bye!

 Lay


[jQuery] Re: problem in removing and moving

2008-12-21 Thread Kean

ul id=notDiv
lib/b/li
lib/b/li
lib/b/li
lib/bspan id=movingI am moving/span/li
lib/b/li
/ul

If i am inserting into any li, regardless where my span#moving is
in (ie. it can be in the third li, fifth li etc)

var idx = 2; //place with other numbers
$(#moving).insertAfter($(#moving).parent('#notDiv').find(li:nth-
child(+idx+) b);

If i am inserting after the previous li, regardless where my
span#moving is in (ie. it can be in the third li, fifth li etc)
Does not account for first-child.
$(#moving).insertAfter($(#moving).parent('li').prev().find('b'));

Code is not tested.

On Dec 20, 4:24 pm, Jack Finger jack.fin...@gmail.com wrote:
 Hi,
 I want to remove an object, but also move a piece of it into previous
 HTML element, does exist something like ':prev' selector? Thanks!
 My code:

 JS:
 $('#to_move').insertAfter('#div  dl:previous(?)  dd');
 $('#div  dl:last').remove();

 HTML:
 fieldset id=div
 dl
   dd...something.../dd !-- MOVE TO HERE --
 /dl
 dl
   dd...something... span id=to_moveTO MOVE/span/dd
 /dl
 /fieldset


[jQuery] Re: Blank input value testing

2008-12-21 Thread Kean

My version plays nice if you have other libraries that take up the $
namespace (ie, prototype framework)

On Dec 21, 7:50 am, Lay András lays...@gmail.com wrote:
 Hello!



 On Sun, Dec 21, 2008 at 3:09 PM, Kean shenan...@gmail.com wrote:
  Well blank() was not created in jQuery.

  You can create a new function for jQuery like this.

  (function($){
   $.fn.blank = function(){
     return $.trim(this[0]).length == 0;
   }
  })(jQuery)

  input id=one value=sadf /
  input id=two value=   /

  $('#one').blank(); // return false
  $('#two').blank(); // return true

  haven't tested the code but should be pointing you to the right
  direction.

 Thank you, this example point me to the right direction. I've made
 minor changes and your code works:

 (function($) {
         $.fn.blank=function() {
                 return $.trim($(this).val()).length==0;
         }

 })(jQuery);

 But this works too:

 $.fn.blank=function() {
         return $.trim($(this).val()).length==0;

 };

 What's the difference between two versions?

 Lay


[jQuery] Re: Opening a popup question

2008-12-17 Thread Kean

var img_name =  $('#bigimage_id_'.her_id).attr(src);

I call attention to this '#bigimage_id_'.her_id

Are you concatenating or what? Use + probably will solve the problem.


[jQuery] Re: Trigger same function from 2 different events

2008-12-17 Thread Kean

Try this

I assume you used the word trigger NOT in a jQuery sense
http://docs.jquery.com/Events/trigger#typedata


jQuery(function($){ //document load/ready
myHandler();

   $('#button').click(myHandler);
});

This code runs myHandler on document load.
The code runs myHandler when #button is clicked.

On Dec 15, 7:07 pm, Dave Methvin dave.meth...@gmail.com wrote:
 You can bind the same handler to multiple events. It sounds like you
 are trying to fake click the button right after load to initialize
 things. I do that a lot.

 $(document).ready(function(){

   $('#mybtn').bind('click init', function(e){
     alert(called because of +e.type);
   }).trigger(init);

 });

 You could also use .triggerHandler(click) instead, but I prefer to
 make it clear the call is because of initialization.


[jQuery] Re: problem with dynamically setting attributes in IE7

2008-12-17 Thread Kean

Some questions I have

1. Did you use a debugger to assure that the attr is set in IE7 on the
first place.
2. Provide some examples?
3. Did you use standard attributes?

On Dec 15, 5:06 pm, RandyJohnson ra...@srpropertiesllc.net wrote:
 I have a jQuery routine that adds attributes to elements dynamically.

 I am able to retrieve the attribute value via $('#id').attr('attr'))
 in FF and Safari.

 When I attempt to retrieve the value in IE7 I get a blank value.

 If I place the attribute in the original HTML and attempt to read with
 IE7 I get the expected attribute value.

 Is this an IE7 feature or I am doing something wrong?

 Thanks in advance...

 Randy


[jQuery] Re: libraries

2008-12-17 Thread Kean

jQuery's API is intuitive by nature, you should learn by heart.

On Dec 16, 5:41 pm, Ricardo Tomasi ricardob...@gmail.com wrote:
 Ah now I see what you mean.

 You can download the extensions for Dreamweaver or IntelliSense 
 athttp://xtnd.us/dreamweaver/jqueryhttp://www.mustafaozcan.net/en/post/2008/06/15/JQuery-1-2-6-Intellise...

 But I think it's more productive to rewrite it from scratch in your
 own format. The Intellisense code is embedded in the comments of the
 script itself, you'd have to create a parser for that.

 On Dec 16, 8:09 pm, Dirceu Barquette dirceu.barque...@gmail.com
 wrote:

  OK. CSV isn't required...
  All the IDE has {css,tagHtml}attrs or jQuery{attr,methods} auto-complete
  cappable . If I have these lists, auto-completing is easy... isn't it?
  Thanks
  Dirceu Barquette

  2008/12/16 Ricardo Tomasi ricardob...@gmail.com

   Hmm.. what do you mean? all of these are plain text, I guess you meant
   something other than 'file format' (and csv has nothing to do with CSS
   by the way, more than the rest is unrelated!) :]

   On Dec 16, 5:22 pm, Dirceu Barquette dirceu.barque...@gmail.com
   wrote:
Hi,

I'd like to know, please:
There is  {HTML,CSS,jQuery}library in [xml,csv,json]file format?
The goal is an IDE...

Thanks.

Dirceu Barquette


[jQuery] Re: Google Analytics breaks jQuery.

2008-12-17 Thread Kean

I think you have to publish some html to get more constructive
responses

On Dec 17, 7:31 am, simshaun simsh...@gmail.com wrote:
 Thanks for the tip. I already am canceling the link's default action
 however.  It is definitely the Google Analytics code on the page I'm
 injecting that's causing it to break.  After I remove Google
 Anaylitics from the injected page, it works fine.

 At the moment, I'm performing something like this:

 $('a').click(function(e){
     e.preventDefault();

     var inject = $(this).attr('href');

    // $('div.container').load() goes here

 }

 On Dec 16, 6:44 pm, Kean shenan...@gmail.com wrote:

  $(a).click(function(){
    do something

    // return false, this is jQuery's way of preventing default or
  bubbling
    return false;

  });

  Hope this helps

  On Dec 16, 11:51 am, simshaun simsh...@gmail.com wrote:

   I have a page where I am using jQuery's load function to inject HTML
   into a div container.

   Right underneath the opening body tag, I've written a script that
   binds an onClick event to all a tags.
   The event fires e.preventDefault(), reads the href attribute, and
   loads that href into a div container.

   At the bottom of the page, I've placed Google Analytics tracking code.

   Instead of loading the link's href into the div container, FireFox
   actually tries to load the link as if I never used e.preventDefault().

   IE seems to work OK though, (or handles it inappropriately and seems
   to work fine.)

   The pages that are supposed to be loaded into the DIV container have
   Google Analytics code as well.
   Once I removed the Analytics code from those pages, everything works
   fine.

   Why does having Google Analytics on pages loaded via the load function
   cause everything to break?


[jQuery] javascript namespacer

2008-12-17 Thread Kean

I wrote a simple namespacer. Do you think this is useful in real world
applications? Any improvements that can be made to the code? Thank
you.

var namespace = function (name, global){
var root = global || '$';

(!eval('window.'+root))? eval('window.' + root + '={}') : '';


var name = name.split(.);
var fullname;
for (var i=0; iname.length; i++) {
fullname = (!i) ? name[i] : fullname + . + name[i];
if (!eval (root + . + fullname))
eval (root + . + fullname +  = {});
}
}

namespace('hello.yahoo');
namespace('helloz.yahoo2');
namespace('helloz.yahoo2', 'YAHOO');



$.hello.yahoo.init = function() { alert(1); };
$.helloz.yahoo2.init = function() { alert(2); };
YAHOO.helloz.yahoo2.init = function() {alert(3); };

$.hello.yahoo.init(); //alerts 1
$.helloz.yahoo2.init(); // alerts 2
YAHOO.helloz.yahoo2.init(); // alerts 3


[jQuery] Re: javascript namespacer

2008-12-17 Thread Kean

Thanks!

I knew eval was bad, that's why I'd posted it here. :)

On Dec 17, 2:24 pm, Ariel Flesler afles...@gmail.com wrote:
 No eval() please!

 function namespace(name, data){
      data = data || window;
      name = name.split(.);

      for (var i=0; i  name.length; i++) {
          var ns = name[i];
          data = data[ns] || ( data[ns] = {} );
      }
      return data;

 };

 It'd a little get shorter if you use jQuery.each.

 Cheers

 --
 Ariel Fleslerhttp://flesler.blogspot.com/

 On Dec 17, 8:05 pm, Kean shenan...@gmail.com wrote:

  I wrote a simple namespacer. Do you think this is useful in real world
  applications? Any improvements that can be made to the code? Thank
  you.

  var namespace = function (name, global){
          var root = global || '$';

          (!eval('window.'+root))? eval('window.' + root + '={}') : '';

          var name = name.split(.);
          var fullname;
          for (var i=0; iname.length; i++) {
                  fullname = (!i) ? name[i] : fullname + . + name[i];
                  if (!eval (root + . + fullname))
                          eval (root + . + fullname +  = {});
          }

  }

  namespace('hello.yahoo');
  namespace('helloz.yahoo2');
  namespace('helloz.yahoo2', 'YAHOO');

  $.hello.yahoo.init = function() { alert(1); };
  $.helloz.yahoo2.init = function() { alert(2); };
  YAHOO.helloz.yahoo2.init = function() {alert(3); };

  $.hello.yahoo.init(); //alerts 1
  $.helloz.yahoo2.init(); // alerts 2
  YAHOO.helloz.yahoo2.init(); // alerts 3


[jQuery] Re: Optimized Code

2008-12-16 Thread Kean

It's interesting to know that $.map and $.grep can be used to a more
generalized approach to this problem. Issya, you should look at
Scott's code as it is extensible for future use. Definitely learned
something new today.

On Dec 15, 8:14 pm, Scott Sauyet li...@sauyet.com wrote:
 issya wrote:
  I recently made this small script and was thinking it is a bit long.
  It works just fine, I was wondering if there is any way to make it
  shorter or is this right? Thanks in advance for the help.

 The previous suggestion, I think missed the point that you were only
 selecting the first option for those that DIDN'T match the selected
 value, so would take some additional work to get working correctly.

 My approach was someone similar.  It's concise, but probably less
 readable than the original.  The advantage is that it easily extensible
 to additional fields.  But it would require that you change the HTML so
 that #id_zip_code became #id_zip.  This is of course entirely untested,
 and probably will throw errors until it's debugged:

 $(document).ready(function() {
      var items = [city, zip, county];
      $($.map(items, function(item, i){return . + item}).join(,)).hide();
      $(. + $(input:checked).val()).show();
      $(input).click(function() {
          var test = $(this).val();
          $($.map(items, function(item, i) {return . +
 item}).join(,)).hide();
          $(. + $(input:checked).val()).show();
          $($.map($.grep(items, function(item, i) {return (item !=
 test);}), function(item, i) {return #id_ + item + 
 option:first}).join(,)).attr(selected, selected);
      });

 });

 I don't know if this is in fact any better than the original code, but
 it is certainly shorter.

 Cheers,

    -- Scott


[jQuery] Re: Google Analytics breaks jQuery.

2008-12-16 Thread Kean

$(a).click(function(){
  do something

  // return false, this is jQuery's way of preventing default or
bubbling
  return false;
});

Hope this helps

On Dec 16, 11:51 am, simshaun simsh...@gmail.com wrote:
 I have a page where I am using jQuery's load function to inject HTML
 into a div container.

 Right underneath the opening body tag, I've written a script that
 binds an onClick event to all a tags.
 The event fires e.preventDefault(), reads the href attribute, and
 loads that href into a div container.

 At the bottom of the page, I've placed Google Analytics tracking code.

 Instead of loading the link's href into the div container, FireFox
 actually tries to load the link as if I never used e.preventDefault().

 IE seems to work OK though, (or handles it inappropriately and seems
 to work fine.)

 The pages that are supposed to be loaded into the DIV container have
 Google Analytics code as well.
 Once I removed the Analytics code from those pages, everything works
 fine.

 Why does having Google Analytics on pages loaded via the load function
 cause everything to break?


[jQuery] Re: Cluetip speed question

2008-12-16 Thread Kean

You most probably guess right on the CSS selector speed.

Here's a link to read on CSS selector optimization.
http://www.thegrubbsian.com/2008/10/optimize-jquery-selector-performance.html

On Dec 16, 2:17 pm, David Morton morto...@gmail.com wrote:
 I am trying to use Cluetip to make a help text for what can be a large list
 - and I'm hearing reports that a list of 100 items with 4-5 columns each is
 causeing IE7 to slow down or appear to freeze for a while, and commenting
 out the cluetip invocation clears it up.   I'm assuming it's jsut due to
 poor javascript speed as it loops over all the DOM to activate all the
 required DOM elements.

 Right now, I'm invoking them all with one command that uses a class to pick
 them up:

 $('.HelpTipAnchor').cluetip({local:true, cluezIndex: 105, showTitle:
 false,cluetipClass: 'maia', arrows: true, localPrefix: #cluetip_,
 attribute: id});

 Is it the $('.class') part that's slow, as I suspect?  Is there anything I
 can do to speed it up?

 --
 David Morton
 morto...@gmail.com  - bulk address
 morto...@dgrmm.net - direct to my server


  1   2   >