Re: [jQuery] Can this be written better (newbie alert)

2007-01-13 Thread Allan Mullan
If there is no need for the additional function you could always just 
write it like so:


$(document).ready(function() {
$('a.taglink').click(function() {
   var t = $(#tags);

   if(!(t.val()) {
  t.val(this.txt);
  return;
   }

   var ss = t.val().split(this.text);

   if(ss.length = 1) {
  var wa = (t.attr('value')+',' +this.text).split(,);
  wa.sort();
  t.val(wa.join());
   }
});


But then again if you're using the tagSelect function for another 
purpose then stick with Christof's code :-)

Allan



Christof Donat wrote:

 Hi,

  Just about getting feet wet with jQuery, wrote a simple function which

  fills an input field with text of the link clicked after sorting the

  comma separated values. It is working as expected but would like to

  know if it can be made more comprehensive.

 Your code is really good for a jQuery beginner ;-) Just small 
 improvements:

 $(document).ready(

 function(){

 // we can directly use the tagSelect-function here, because I changed

 // it to use this.text - what is this.text anway? Do you mean

 // $(this).html()?

 $('a.taglink').click(tagSelect);

 }

 );

 function tagSelect() {

 var t = $('#tags'); // this is used very often; if you meant

 // $(this).html(), store it in a local variable as

 // well, like

 // var txt = $(this).html();

 if( !t.val() ) {

 t.val(this.text);

 return;

 }

 var ss = t.val().split(this.text);

 if ( ss.length = 1 ) {

 // don't use t.val to store a temporary value.

 var wa = (t.attr('value')+',' +this.text).split(,);

 wa.sort();

 t.val(wa.join()); // you always change t.val() again here

 }

 }

 Christof

 

 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
   

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] jQuery Powered Sites - Keep the Links Coming

2007-01-13 Thread Philippe Jadin

Please keep sending links as we want to have a nice list of
jQuery-powered sites for the jQuery web site.



http://www.100drine.be/blog/ uses jquery for the electronic postcards. If
you hover on any image in the content area, there is a big red button that
says send this picture as an ecard. The site is in french, and endorsed by
the Belgian public service Yapaka (www.yapaka.be), a government campaign
that helps people (in this case, teens) talk to each other


Philippe


Thanks,


Rey...

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





--
Philippe Jadin
Thinkedit, a flexible
data and content
management system :
http://www.thinkedit.org
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Can this be written better (newbie alert)

2007-01-13 Thread Dr. Tarique Sani
On 1/13/07, Christof Donat [EMAIL PROTECTED] wrote:
 Your code is really good for a jQuery beginner ;-) Just small improvements:

Thanks for the compliment and many more thanks for the *small*
improvements. Everything worked as you said and this was exactly what
I was looking for.

To clarify I was using this.text to get the text between a /a but
var txt = $(this).html() works :)

I tried taking this to the next level. Now I wanted the links to be
loaded via ajax and then clicking on the links would insert them in an
input field

So while this works

$(document).ready(
function(){
$('#getTags').click(
function(){

$('#taglist').load('http://tarique.sanisoft.com/cheesecake/tags/taglist',
function(){ $('a.taglink').click(
function(){
tagSelect(this.text);
return false;
}
)
}
);
return false;
}
)
}
);

This fails

$(document).ready(
function(){
$('#getTags').click(
function(){

$('#taglist').load('http://tarique.sanisoft.com/cheesecake/tags/taglist',
function(){ $('a.taglink').click(tagSelect);
}
)
}
);
return false;
}
)
}
);

Can put up a demo of what I am trying to do if that would make things easier.

Thanks in advance

Tarique

P.S. Allan - yes I need the function at other places

-- 
=
PHP Applications for E-Biz: http://www.sanisoft.com
Cheesecake-Photoblog: http://cheesecake-photoblog.org
=

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Can this be written better (newbie alert)

2007-01-13 Thread Christof Donat
Hi,

 This fails

Your parentheses are wrong. I just reformated your code and here is the 
result:

$(document).ready(function() {
  $('#getTags').click(function() {
$('#taglist').load('http://tarique.sanisoft.com/cheesecake/tags/taglist', 
function() {
  $('a.taglink').click(tagSelect);
});
  });
}); // here the statement ends and the rest leads to a parse error in the JS 
interpreter.
} 
);

Christof

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] dynamic loading of jquery.js into my web page

2007-01-13 Thread Andrea Ercolino


Christof Donat wrote:
 
 @Andrea: can you please check, if that was the problem for you?
 

Your test page works now :-)

But I still have the same problem...
Here is a zip file. After unzipping, there will be a new chili folder with
a test page and a subfolder. It works in FF1.5.0.9 but does not in IE7.
http://www.nabble.com/file/5620/chili.zip chili.zip 
-- 
View this message in context: 
http://www.nabble.com/dynamic-loading-of-jquery.js-into-my-web-page-tf2905089.html#a8313016
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] form.js jorn's validation

2007-01-13 Thread Jörn Zaefferer
Gerry Tucker schrieb:
 Hi all... again!!!
  
 I know this is down to my only general knowledge of javascript but I'm 
 trying to use Jorn's validation plugin, and I assumed I would need to 
 use the form.js plugin as well.
  
 My VERY simple problem is how to do this, because so far I have only 
 managed to validate the form AND submit it to my PHP page regardless 
 of whether the form was valid or not.
  
 I'd post some code but I'm too embarrased !
  
 If anyone has done used both plugins together, or even has a generic 
 solution that will work I'd be very grateful.  I've just completely 
 rewritten a very large site to completely use jQuery and forms are the 
 only outstanding issue I have.
The online version of the plugin doesn't use the form plugin. I've 
worked on a new version, but never got it done.

Until then, see this message on how to add a callback hook for the form 
plugin: 
http://www.nabble.com/Form-Validation-%28no-Ajax%29-tf2622391.html#a7331366

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] A perfect example...

2007-01-13 Thread Klaus Hartl
...why sticking to standards is good - microsoft is having the problems 
they created:
http://blogs.msdn.com/iemobile/archive/2006/12/18/why-doesn-t-adobe-flash-always-render-for-ie-mobile.aspx


LOL, digg it!

http://digg.com/software/Microsoft_having_the_problems_they_created


Sorry for OT, I just had to post this...


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Can this be written better (newbie alert)

2007-01-13 Thread Christof Donat
Hi,

 My problem now is how to get the value of text which is between a
 /a of the clicked link, - now the scope of $(this) is different.

 In the first case it work because $(this) was [a.taglink
 cheeseCake...] but with the above $(this) becomes [Window
 addphoto.html]

Hm, this sounds strange. You have multiple contexts in your code:

$(document).ready(function() {
  // this should be document
  $('#getTags').click(function() {
// this should be the element with the ID 'getTags'
    $('#taglist').load('http://tarique.sanisoft.com/cheesecake/tags/taglist', 
function() {
  // this should be the element with the ID 'taglist'
      $('a.taglink').click(tagSelect /*in tagSelect this should be a link with 
the class 'taglink'. */ );
    });
  });
});

Where exactly do you have window as this. There must be something wrong.
are you shure that you have written $('a.taglink').click(tagSelect) and 
not $('a.taglink').click(tagSelect())?

Christof

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Height of images on page load.

2007-01-13 Thread Abel Tamayo

Ok. I give Up. I need to know the height of certain images in my page to be
able to format it and I've tried several workarounds like this function that
I call right before my verJustify() function (yeah, a function that lets me
justify vertically all divs in my page, just like the plug in):

/**
* Calculates the height of every image in the selection.
* Necesary for vertical justifying purposes.
* Has to be called before verJustify().
* @see verJustify()
* @example calHeight(#left);
* @param string query - The selection to be precalculated
* @return none
*/
function calHeight(query){
   query = query +  img;
   $(query).each(function(){
 $(this).css(height, $(this).css(height));
   });
}

The problem with my layout is that basically every image's size is set
dinamically when the page loads. Like a liquid layout but instead of using
CSS and text, with a lot of images and JavaScript.

My theory was: ok, if Firefox doesn't calculate the width of an image before
the formatting of the page, maybe i can force it to do it.
It works for some things but not for others and I don't know what else to
try. The funny thing is that, in debugging mode, if I set a breakpoint to
this function and then just let it execute, it works perfectly, but if I
don't pause it manually it seems like there's not enough time to calculate
every image's height.


¿Any suggestions?
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] dynamic loading of jquery.js into my web page

2007-01-13 Thread Christof Donat
Hi,

 Your test page works now :-)

Great :-) 

 But I still have the same problem...
 Here is a zip file. After unzipping, there will be a new chili folder
 with a test page and a subfolder. It works in FF1.5.0.9 but does not in
 IE7. http://www.nabble.com/file/5620/chili.zip chili.zip

Currrently I don't have IE7 at hand - on monday again.

I tried your code with Firefox 2.0, Opera 9.02 and Konqueror 3.5.5 on Linux. 
Firefox is OK, Opera has huge linespaces, but shows the colors. Konqueror 
doesn't do any coloring at all, but an alert() in the calback of $using() in 
chili.js fires. I guess you have tried that alert with IE as well.

BTW.: I usually don't write the packageBase in package_src.js. I keep that as 
it is an overwrite it outside. That way I don't have any problems when 
changing to the compressed package.js.

Christof

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] [jquery] what if the button wasn't there when the page loaded?

2007-01-13 Thread Daniel McBrearty
suppose we have some content to a page that gets loaded via AJAX in
response to some other event ... it looks like this :

input type=button id=some_new_button


how do I bind to this, in a simple way?

$(function() {
 $(#some_new_button).click( function() { ... };
});

doesn't work because the button didn't happen until after the doc loaded ...

any ideas?

-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?

2007-01-13 Thread Daniel McBrearty
I'm looking at

http://jquery.bassistance.de/jquery-getting-started.html#rate

where it says:


SNIP
A very common problem encountered when loading content by AJAX is
this: When adding event handlers to your document that should also
apply to the loaded content, you have to apply these handlers after
the content is loaded. To prevent code duplication, you can delegate
to a function. Example:

// lets use the shortcut
$(function() {
var addClickHandlers = function() {
$(a.clickMeToLoadContent).click(function() {
$(#target).load(this.href, addClickHandlers);
});
};
addClickHandlers();
});

Now addClickHandlers is applied once when the DOM is ready and then
everytime when a user clicked a link with the class
clickMeToLoadContent and the content has finished loading.

/SNIP

but I'm not quite getting to this. First I don't understand :

$(#target).load(this.href, addClickHandlers);

because I'm only finding docs for a load function with a single func
argument ... what is this.href doing?

does this mean that addClickHandlers gets called EACH time #target loads?

thanks

Daniel

On 1/13/07, Daniel McBrearty [EMAIL PROTECTED] wrote:
 suppose we have some content to a page that gets loaded via AJAX in
 response to some other event ... it looks like this :

 input type=button id=some_new_button


 how do I bind to this, in a simple way?

 $(function() {
  $(#some_new_button).click( function() { ... };
 });

 doesn't work because the button didn't happen until after the doc loaded ...

 any ideas?

 --
 Daniel McBrearty
 email : danielmcbrearty at gmail.com
 www.engoi.com : the multi - language vocab trainer
 BTW : 0873928131



-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] [plugin] jdMenu - Finally Released!

2007-01-13 Thread Jörn Zaefferer
Jonathan Sharp schrieb:
 I finally got around to finishing the pages and packaging the plugin 
 last night. Enjoy!
  
 http://jdsharp.us/code/jQuery/plugins/jdMenu/
Great to see an update to this plugin!

Have you considered or tried an event delegation approach? That is, 
assign the click handlers to the entire menu instead of each li, and use 
the event's target property then. You'd have less event handlers, though 
more code to figure what to do when the event is fired. And you can add 
and remove as many elements as you like, there would be no need to un- 
or rebind any event handlers.

For 1.1 compability, I think the only thing you have to change is 
ancestors() to parents().

Maybe we should move ancestorsUntil (or rather, parentsUntil) and 
next/prevUntil to it's own plugin. You could then provide both 
jdMenu-only package and a jdMenu-with-dependencies package.

The bgiframe plugin is really easy to use, you just apply it to all 
elements that need the iframe.

Of course it would be nice to customize the behaviour via options, but 
that was also mentioned before.

And a hint that works from 1.1 on:
The intialization code at the top depends on the $ alias. You can avoid 
that even without the custom alias pattern used for the plugin itself.
As of 1.1, a reference to the jQuery function is passed as an argument 
to the document ready event. So you can rewrite this:

$(function(){
$('ul.jd_menu').jdMenu();
$(document).bind('click', function() {
$('ul.jd_menu ul:visible').jdMenuHide();
});
});

To this:

jQuery(function($){
$('ul.jd_menu').jdMenu();
$(document).bind('click', function() {
$('ul.jd_menu ul:visible').jdMenuHide();
});
});

And none of the code would depend any more on the $ alias being present.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] State of IE 5.5 compatibility

2007-01-13 Thread Jörn Zaefferer
Steve Owsinski schrieb:
 Hey everyone,

 I recall a while back that jQuery was stated as compatible with IE
 5.5. I see on the new docs.jquery.com wiki that it has known
 problems. Is there a place that documents any of these issues?
 Primarily, I'm wondering if most of the basic functionality works with
 5.5 (it does as far as I can tell based on some sites I have running
 with jQuery), and if there are plans to make sure that the code still
 is parsed without flagging errors in 5.5 (that is, without alerting
 the user of a scripting error because some jQuery code makes 5.5 choke
 when parsing it the first time). Even if it doesn't have full 5.5
 compatibility, it would be awesome if it stayed non-error-causing, and
 mostly-functional at least for the next year or two. Thoughts?

 I really appreciate the hard work--it is making my life seriously easier.
   
According to the test suite, 5.5 fails about 10% of the tests, that 
isn't too bad.

You could please post this as a bug report? http://jquery.com/dev/bugs/new/

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] error using jdMenu.js

2007-01-13 Thread Stefan Kilp [sk-software]
adding the compatibility plugin from here

http://jquery.com/dev/svn/trunk/plugins/compat-1.0/jquery.compat-1.0.js?format=txt

solved thew problem.

thanks
stefan

  try to use jdMenu with jquery-1.1b.js i receive an error:
 
 
  $(this[0]).ancestors is not a function
  in jquery.jdMenu.js (Line 28)
 
 
 Um, you quoted the answer to your own question.
 
 
Excellent work , Jonathan!   Note that the compatibility plugin is
necessary for use with jQuery v1.1.
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/


--
Stefan Kilp
SK-Software, Entwicklung  Beratung

email: [EMAIL PROTECTED]

fon  : +49 6151 93344-0
fax  : +49 6151 93344-20
Herta-Mansbacher-Str. 98
64289 Darmstadt, Germany.
-


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?

2007-01-13 Thread Daniel McBrearty
thanks ... this still isn't making any sense to me though.

the docs say that load

Bind a function to the load event of each matched element.

IOW ... it doesn't actually load anything - it causes some function to
get executed each time that element finishes loading.


 I believe the online docs are accurate, but load is a flexible
 function that you can pass one, two or three args.  And href is an
 important one - that's what you're loading!

 $('#target').load('myFile.html');

so this just loads myFile without and other function getting executed?
loads it where? this is an element  ie a button, a link or
whatever ... how can you load an html file into it?

sorry if this is a dumb q ... but this completely doesn't make sense
to me. If I failed to R some basic bit of TFM I'd be glad of a pointer
...

thanks again.

-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?

2007-01-13 Thread Mike Alsup
 the docs say that load

 Bind a function to the load event of each matched element.

But if you notice, the docs indicate there is more than one load
function.  The one you're quoting is a bind for the load event.
You're invoking a load action directly for which the docs say:

Load HTML from a remote file and inject it into the DOM.


 so this just loads myFile without and other function getting executed?
 loads it where? this is an element  ie a button, a link or
 whatever ... how can you load an html file into it?

It loads the file into the jQuery selection.  For example:

$('#target').load('somefile.html')

will load somefile.html into #target and

$('.targets').load('somefile.html')

will load somefile.html into all of the elements with class attribute
of 'targets'.


If you're trying to attach this behavior to a button click then you
might consider something like this:

$('#myButton').click(function() {
$('#myTarget').load('myfile.html' function() {
alert('my callback');
});
});

The above says: when myButton is clicked, load myfile.html into
myTarget and alert me when it's done.

Hope this helps.

Mike

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Retriving actual height of element in IE *and* FF

2007-01-13 Thread Dan Atkinson

Yup, that would be it!

Using 1.1a on my test site. Updated to 1.1b and it's working!

I was under the impression that these methods would be removed and replaced
wholly with their respective parent methods like css().

So, would the following be acceptable, do you think? ::

$(div#content).css(height,$(#content).height()+px);

Cheers,

Dan Atkinson


Karl Swedberg-2 wrote:
 
 Dan,
 
 .height() was pulled out of 1.1a, but it's back in as of 1.1b. If  
 you're using 1.1a, that could be the problem.
 
 
 --Karl
 _
 Karl Swedberg
 www.englishrules.com
 www.learningjquery.com
 
 
 
 On Jan 13, 2007, at 7:54 AM, Dan Atkinson wrote:
 

 Thanks for the reply.

 It returned:
 $(#content).height is not a function


 Brandon Aaron wrote:

 Try using .height(). It will return the computed height value in
 pixels as in integer.

 --
 Brandon Aaron

 On 1/12/07, Dan Atkinson [EMAIL PROTECTED] wrote:

 Hey there!

 I'm currently doing some jQuery work on my blog which involves  
 some a bit
 of
 code to handle internal link clicks (same domain, not #) which will
 change
 anything in the main content div:
   * Sets the height of the main content div to the current height
   * Fadeout the child elements and then empty on callback
 ($(div#content).children().fadeOut('slow',function(){$ 
 (div#content).empty();}))
   * Repopulate with new content from server in AJAX call.

 My problem here in all this is that the actual height (in px)  
 isn't being
 returned in IE, but is being returned in Firefox. What IE returns  
 is the
 CSS
 value of the div, but not the actual current value, which is what  
 I want.
 Is
 there something I can use? I tried offsetHeight but that's not  
 right.

 Is there anything I'm missing?!

 -- 
 View this message in context: http://www.nabble.com/Retriving- 
 actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8313889
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Retriving-actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8314900
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?

2007-01-13 Thread Webunity | Gilles van den Hoven

 $('#myButton').click(function() {
 $('#myTarget').load('myfile.html' function() {
 alert('my callback');
 });
 });

 The above says: when myButton is clicked, load myfile.html into
 myTarget and alert me when it's done.
   
And then you can rebind any event handlers you want, but do this only 
on the #myTarget, else the events get binded twice to the other elements 
allready binded.

Gilles

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Retriving actual height of element in IE *and* FF

2007-01-13 Thread Brandon Aaron
.height() is also a setter and defaults the unit to pixels if not
provided. So you can do it like this:

$(div#content).height( $(#content).height() );

--
Brandon Aaron

On 1/13/07, Dan Atkinson [EMAIL PROTECTED] wrote:

 Yup, that would be it!

 Using 1.1a on my test site. Updated to 1.1b and it's working!

 I was under the impression that these methods would be removed and replaced
 wholly with their respective parent methods like css().

 So, would the following be acceptable, do you think? ::

 $(div#content).css(height,$(#content).height()+px);

 Cheers,

 Dan Atkinson


 Karl Swedberg-2 wrote:
 
  Dan,
 
  .height() was pulled out of 1.1a, but it's back in as of 1.1b. If
  you're using 1.1a, that could be the problem.
 
 
  --Karl
  _
  Karl Swedberg
  www.englishrules.com
  www.learningjquery.com
 
 
 
  On Jan 13, 2007, at 7:54 AM, Dan Atkinson wrote:
 
 
  Thanks for the reply.
 
  It returned:
  $(#content).height is not a function
 
 
  Brandon Aaron wrote:
 
  Try using .height(). It will return the computed height value in
  pixels as in integer.
 
  --
  Brandon Aaron
 
  On 1/12/07, Dan Atkinson [EMAIL PROTECTED] wrote:
 
  Hey there!
 
  I'm currently doing some jQuery work on my blog which involves
  some a bit
  of
  code to handle internal link clicks (same domain, not #) which will
  change
  anything in the main content div:
* Sets the height of the main content div to the current height
* Fadeout the child elements and then empty on callback
  ($(div#content).children().fadeOut('slow',function(){$
  (div#content).empty();}))
* Repopulate with new content from server in AJAX call.
 
  My problem here in all this is that the actual height (in px)
  isn't being
  returned in IE, but is being returned in Firefox. What IE returns
  is the
  CSS
  value of the div, but not the actual current value, which is what
  I want.
  Is
  there something I can use? I tried offsetHeight but that's not
  right.
 
  Is there anything I'm missing?!
 
  --
  View this message in context: http://www.nabble.com/Retriving-
  actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8313889
  Sent from the JQuery mailing list archive at Nabble.com.
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context: 
 http://www.nabble.com/Retriving-actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8314900
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Retriving actual height of element in IE *and* FF

2007-01-13 Thread Dan Atkinson

Lol! Yes, that would make sense!

Thanks for the responses on this.


Brandon Aaron wrote:
 
 .height() is also a setter and defaults the unit to pixels if not
 provided. So you can do it like this:
 
 $(div#content).height( $(#content).height() );
 
 --
 Brandon Aaron
 
 On 1/13/07, Dan Atkinson [EMAIL PROTECTED] wrote:

 Yup, that would be it!

 Using 1.1a on my test site. Updated to 1.1b and it's working!

 I was under the impression that these methods would be removed and
 replaced
 wholly with their respective parent methods like css().

 So, would the following be acceptable, do you think? ::

 $(div#content).css(height,$(#content).height()+px);

 Cheers,

 Dan Atkinson


 Karl Swedberg-2 wrote:
 
  Dan,
 
  .height() was pulled out of 1.1a, but it's back in as of 1.1b. If
  you're using 1.1a, that could be the problem.
 
 
  --Karl
  _
  Karl Swedberg
  www.englishrules.com
  www.learningjquery.com
 
 
 
  On Jan 13, 2007, at 7:54 AM, Dan Atkinson wrote:
 
 
  Thanks for the reply.
 
  It returned:
  $(#content).height is not a function
 
 
  Brandon Aaron wrote:
 
  Try using .height(). It will return the computed height value in
  pixels as in integer.
 
  --
  Brandon Aaron
 
  On 1/12/07, Dan Atkinson [EMAIL PROTECTED] wrote:
 
  Hey there!
 
  I'm currently doing some jQuery work on my blog which involves
  some a bit
  of
  code to handle internal link clicks (same domain, not #) which will
  change
  anything in the main content div:
* Sets the height of the main content div to the current height
* Fadeout the child elements and then empty on callback
  ($(div#content).children().fadeOut('slow',function(){$
  (div#content).empty();}))
* Repopulate with new content from server in AJAX call.
 
  My problem here in all this is that the actual height (in px)
  isn't being
  returned in IE, but is being returned in Firefox. What IE returns
  is the
  CSS
  value of the div, but not the actual current value, which is what
  I want.
  Is
  there something I can use? I tried offsetHeight but that's not
  right.
 
  Is there anything I'm missing?!
 
  --
  View this message in context: http://www.nabble.com/Retriving-
  actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8313889
  Sent from the JQuery mailing list archive at Nabble.com.
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 
 

 --
 View this message in context:
 http://www.nabble.com/Retriving-actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8314900
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/

 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Retriving-actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8315267
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] [jquery] what if the button wasn't there when the page loaded?

2007-01-13 Thread Daniel McBrearty
On 1/13/07, Mike Alsup [EMAIL PROTECTED] wrote:
  the docs say that load
 
  Bind a function to the load event of each matched element.

 But if you notice, the docs indicate there is more than one load
 function.  The one you're quoting is a bind for the load event.
 You're invoking a load action directly for which the docs say:


ahah. silly me. I was looking under events, didn't see the one under Ajax ...

http://docs.jquery.com/Events


 Hope this helps.


it does, lots. Thanks!


-- 
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Look Ma no IMG-tag - FaviconLinkMarker Beta3 out

2007-01-13 Thread Olaf Bosch
Olaf Bosch schrieb:

 Good, new version for testing. I have found a way to check Favicon 
 exist. Than change the path. Look at: 
 http://olaf-bosch.de/bugs/jquery/links5.html
 
 JQuery, the second Link have no Favicon, cuesrc is changed, see
 alert. What is to do that this works as global in the Script? Now is
 cuesrc not working by the Link, look in generated HTML, please. Don't
 changed :(
 
 Please help me

Hm, no ideas?

I have updated, now you cane give in fourth parameter the default image
for failed favicon.

The function of testing the exist of favicon is not work in the progress
of the script, work after the script!?
I see no way to self repair, any tips are welcome.

See the Demo und see the alerts, is correct path are after the script is
complete.
All Script is in the head of document, for faster help ;)

-- 
Viele Grüße, Olaf

---
[EMAIL PROTECTED]
http://olaf-bosch.de
www.akitafreund.de
---

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] override href link with jquery

2007-01-13 Thread bmsterling

I am not total sure I understand what your asking, but it sounds like you
want the link to load a page into a certain part of your current page, in
other words, you have an html page that you want to load into another html
maybe using ajax?  if this correct, check out the $.ajax function with a
data type of HTML.
-- 
View this message in context: 
http://www.nabble.com/override-href-link-with-jquery-tf2970809.html#a8316419
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Retriving actual height of element in IE *and* FF

2007-01-13 Thread Karl Swedberg
Hey Dan,
Glad that worked. You're right: the plan was to remove all of these  
shorthand methods and replace them with .attr() or .css().

But it was later determined that height() and width() are just too  
convenient to get rid of, especially when we want to use its value in  
some sort of a calculation because it gives us only the numeral  
without the corresponding unit of measurement.

So, if div id=container is 500px tall:
-- $('#container).css('height') == 500px
-- $('#container).height() == 500

Oh, and thanks to Brandon for mentioning about .height() being a  
setter, too.

--Karl

On Jan 13, 2007, at 10:05 AM, Dan Atkinson wrote:


 Yup, that would be it!

 Using 1.1a on my test site. Updated to 1.1b and it's working!

 I was under the impression that these methods would be removed and  
 replaced
 wholly with their respective parent methods like css().

 So, would the following be acceptable, do you think? ::

 $(div#content).css(height,$(#content).height()+px);

 Cheers,

 Dan Atkinson


 Karl Swedberg-2 wrote:

 Dan,

 .height() was pulled out of 1.1a, but it's back in as of 1.1b. If
 you're using 1.1a, that could be the problem.


 --Karl
 _
 Karl Swedberg
 www.englishrules.com
 www.learningjquery.com



 On Jan 13, 2007, at 7:54 AM, Dan Atkinson wrote:


 Thanks for the reply.

 It returned:
 $(#content).height is not a function


 Brandon Aaron wrote:

 Try using .height(). It will return the computed height value in
 pixels as in integer.

 --
 Brandon Aaron

 On 1/12/07, Dan Atkinson [EMAIL PROTECTED] wrote:

 Hey there!

 I'm currently doing some jQuery work on my blog which involves
 some a bit
 of
 code to handle internal link clicks (same domain, not #) which  
 will
 change
 anything in the main content div:
   * Sets the height of the main content div to the current height
   * Fadeout the child elements and then empty on callback
 ($(div#content).children().fadeOut('slow',function(){$
 (div#content).empty();}))
   * Repopulate with new content from server in AJAX call.

 My problem here in all this is that the actual height (in px)
 isn't being
 returned in IE, but is being returned in Firefox. What IE returns
 is the
 CSS
 value of the div, but not the actual current value, which is what
 I want.
 Is
 there something I can use? I tried offsetHeight but that's not
 right.

 Is there anything I'm missing?!

 -- 
 View this message in context: http://www.nabble.com/Retriving-
 actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8313889
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



 -- 
 View this message in context: http://www.nabble.com/Retriving- 
 actual-height-of-element-in-IE-*and*-FF-tf2969737.html#a8314900
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Photo stickies/tagging (like Flickr notes)

2007-01-13 Thread Jamie Wilkinson
Was curious if anyone had seen anything like the photo notes on  
Flickr and Facebook, where you can associate some metadata with a  
specific rect over an image. e.g. http://www.flickr.com/photos/ 
malingering/197630061/in/pool-ihatestupidpeople/  (mouseover the image)

Not sure what these are called generally. Wanted to ask before I go  
reinventing the wheel, too!

Thanks,
-jamie

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Select third column of the table

2007-01-13 Thread Jökull

One way to do it:

$(#table tr).each(function(){
$(this).find(td:eq(2)).dosomething;
});

Does anyone have a quicker way to do it?


Jacky-10 wrote:
 
 Dear all,
 
 If I want to select the 3rd column of the table, (e.g. 3 rows)
 $(tr  td:eq(2)) would returns only one td.
 $(tr).find(td:eq(2)) would returns 3 td.
 
 Is that :eq(2) is applied to the whole trtd set? Is that correct?
 
 -- 
 Best Regards,
 Jacky
 網絡暴民 http://jacky.seezone.net
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Select-third-column-of-the-table-tf2964268.html#a8294492
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Select third column of the table

2007-01-13 Thread Jökull

Is .each redundant?

Does .find support functions like this?

$(#table tr).each.find(td:eq(2))(function(){
$(this).dosomething;
});


Jökull wrote:
 
 One way to do it:
 
 $(#table tr).each(function(){
 $(this).find(td:eq(2)).dosomething;
 });
 
 Does anyone have a quicker way to do it?
 
 
 Jacky-10 wrote:
 
 Dear all,
 
 If I want to select the 3rd column of the table, (e.g. 3 rows)
 $(tr  td:eq(2)) would returns only one td.
 $(tr).find(td:eq(2)) would returns 3 td.
 
 Is that :eq(2) is applied to the whole trtd set? Is that correct?
 
 -- 
 Best Regards,
 Jacky
 網絡暴民 http://jacky.seezone.net
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Select-third-column-of-the-table-tf2964268.html#a8318254
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Select third column of the table

2007-01-13 Thread Nate Cavanaugh

You actually can do it this way:
$('trtd:nth-child(3)');

The reason why eq(N) returns just one, is that you're telling it grab the
nth one you find out of a set.
The code I pasted above grabs the nth CHILD of the tr, so it will return
what you want.

Hope that helps :) 


Jacky-10 wrote:
 
 Dear all,
 
 If I want to select the 3rd column of the table, (e.g. 3 rows)
 $(tr  td:eq(2)) would returns only one td.
 $(tr).find(td:eq(2)) would returns 3 td.
 
 Is that :eq(2) is applied to the whole trtd set? Is that correct?
 
 -- 
 Best Regards,
 Jacky
 網絡暴民 http://jacky.seezone.net
 
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/
 
 

-- 
View this message in context: 
http://www.nabble.com/Select-third-column-of-the-table-tf2964268.html#a8318538
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] What is this question, this one about filters

2007-01-13 Thread bmckenzie

Greetings.

I'm trying to get a list of forms from a DIV where the form's done input
is set to 1 or 0 .

Why does this code throw an error (this.done.value has no properties) ?

   var myForms = $('.actionForm', myDiv).filter(function(){
  return this.done.value==1 ; 
   });
 
I can get the values like this:

   var myForms = $('.actionForm', myDiv);
  $( myForms ).each(function(){
 alert(this.done.value); //displays 1 or 0
   });

So I guess this depends on what the meaning of this is, eh?

Bruce



-- 
View this message in context: 
http://www.nabble.com/What-is-%22this%22-question%2C-this-one-about-filters-tf2973568.html#a8319669
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What is this question, this one about filters

2007-01-13 Thread Ⓙⓐⓚⓔ
this is this here and that there!
inside the each, this is a element.
inside the filter it's the jq object that contains all your actionform
classed items inside myDiv.

On 1/13/07, bmckenzie [EMAIL PROTECTED] wrote:

 Greetings.

 I'm trying to get a list of forms from a DIV where the form's done input
 is set to 1 or 0 .

 Why does this code throw an error (this.done.value has no properties) ?

var myForms = $('.actionForm', myDiv).filter(function(){
   return this.done.value==1 ;
});

 I can get the values like this:

var myForms = $('.actionForm', myDiv);
   $( myForms ).each(function(){
  alert(this.done.value); //displays 1 or 0
});

 So I guess this depends on what the meaning of this is, eh?

 Bruce



 --
 View this message in context: 
 http://www.nabble.com/What-is-%22this%22-question%2C-this-one-about-filters-tf2973568.html#a8319669
 Sent from the JQuery mailing list archive at Nabble.com.


 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What is this question, this one about filters

2007-01-13 Thread Ⓙⓐⓚⓔ
I hope I got the filter right... I looked back at some of my similar code,

jQuery.fn.randomOne=function(){
return this.eq( Math.floor(Math.random()*this.length));
}

is a simple plugin to get (in my case) one random element and this
is the jq element.

On 1/13/07, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:
 this is this here and that there!
 inside the each, this is a element.
 inside the filter it's the jq object that contains all your actionform
 classed items inside myDiv.

 On 1/13/07, bmckenzie [EMAIL PROTECTED] wrote:
 
  Greetings.
 
  I'm trying to get a list of forms from a DIV where the form's done input
  is set to 1 or 0 .
 
  Why does this code throw an error (this.done.value has no properties) ?
 
 var myForms = $('.actionForm', myDiv).filter(function(){
return this.done.value==1 ;
 });
 
  I can get the values like this:
 
 var myForms = $('.actionForm', myDiv);
$( myForms ).each(function(){
   alert(this.done.value); //displays 1 or 0
 });
 
  So I guess this depends on what the meaning of this is, eh?
 
  Bruce
 
 
 
  --
  View this message in context: 
  http://www.nabble.com/What-is-%22this%22-question%2C-this-one-about-filters-tf2973568.html#a8319669
  Sent from the JQuery mailing list archive at Nabble.com.
 
 
  ___
  jQuery mailing list
  discuss@jquery.com
  http://jquery.com/discuss/
 


 --
 Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ



-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] new plugin: DOM pre-order traversal

2007-01-13 Thread bander

At ShockSMX's request and with John's help, I've created a plugin which
traverses the DOM in natural/onscreen order. It's my first plugin, so let me
know if you find any bugs or know what would make it more useful. (For
example, would you like me to accept a parameter which skips hidden nodes?)
Check it out here:

http://bluej.freeshell.org/jquery/domIterate.html

I've used my editable code execution fields, so play around with it as you
like. Hope it's helpful.
-- 
View this message in context: 
http://www.nabble.com/new-plugin%3A-DOM-pre-order-traversal-tf2975733.html#a8322059
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What is this question, this one about filters

2007-01-13 Thread bmckenzie



Rigent wrote:
 
 You're not setting the done input to 0 or 1 because you have the double
 '=' in there, it should be:
 
 return this.done.value = 1; 
 
 

Actually, I want a  collection containing the forms where the field done
has already been set to 1.

B.

-- 
View this message in context: 
http://www.nabble.com/What-is-%22this%22-question%2C-this-one-about-filters-tf2973568.html#a8322522
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Retriving actual height of element in IE *and* FF

2007-01-13 Thread Jörn Zaefferer

 So, if div id=container is 500px tall:
 -- $('#container).css('height') == 500px
 -- $('#container).height() == 500

 Oh, and thanks to Brandon for mentioning about .height() being a  
 setter, too.
   
In addition to that, css() converts any values given as Numbers to 
Strings, so you can do both:

$(...).css(height, 500px)
$(...).css(height, 500)

Both are useful: When you retrieve one value via css and have a string 
with pixel, you can set it to another style or element. And it also 
works for top or whatever style accepts a pixel value.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] What is this question, this one about filters

2007-01-13 Thread Jörn Zaefferer
bmckenzie schrieb:
 So I guess this depends on what the meaning of this is, eh?
   
The filter(function) needs jQuery 1.1a+ to work correctly. Older 
versions accept the Function, but apply different scope and different 
arguments.

I suspect that this is the reason why it isn't working, I can't see 
anything wrong with your code. If an upgrade doesn't help: Please 
provide a simple test page.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Beginner question re: getting and setting element class name

2007-01-13 Thread Miles Storey

Hi, I'm just starting to use jQuery and, while I'm not much of a coder, I
love the way it works. I was developing a project using the Prototype
library, but after discovering jQuery I'm converting everything. I'm finding
it straightforward but I have a request for a clarification on something.

I have a function that branches depending on the class name of the element
that was passed to it.

Using Prototype:

function checkState(id) {
 if ($(id).className == something) { etc

but in jQuery it doesn't work. It does work if I use:

if ($(id).attr(class) == something) { etc

I'm just wondering, as a beginner, if that would be the most 'correct' way
to do it.

Also, if I want to toggle the class name of an element between say active
and inactive what is the easiest way to do that? From the documentation I
see that addClass won't replace the existing class so it looks like the best
way is to use the attr(key,value) method and do something like:

$(id).attr(class, active)

It works, I'm just looking for 'best practise' advice.

Thanks
Miles
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Interface : 'sort floats' problem

2007-01-13 Thread Olaf Bosch
Kush schrieb:

 Any ideas, why it happens when you place it inside another div for
 example.

Your selector is not right, try
$('#container').Sortable(

-- 
Viele Grüße, Olaf

---
[EMAIL PROTECTED]
http://olaf-bosch.de
www.akitafreund.de
---

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Interface : 'sort floats' problem

2007-01-13 Thread Kush
Silly me, thanks heaps Olaf
That fixed the problem :)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Olaf Bosch
Sent: Sunday, 14 January 2007 2:01 PM
To: jQuery Discussion.
Subject: Re: [jQuery] Interface : 'sort floats' problem

Kush schrieb:

 Any ideas, why it happens when you place it inside another div for
 example.

Your selector is not right, try
$('#container').Sortable(

-- 
Viele Grüße, Olaf

---
[EMAIL PROTECTED]
http://olaf-bosch.de
www.akitafreund.de
---

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Beginner question re: getting and setting element class name

2007-01-13 Thread Mike Alsup
 function checkState(id) {
   if ($(id).className == something) { etc

Use the is method:

$(id).is(something);

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Beginner question re: getting and setting element class name

2007-01-13 Thread Karl Swedberg

On Jan 13, 2007, at 9:52 PM, Miles Storey wrote:

 Hi, I'm just starting to use jQuery and, while I'm not much of a  
 coder, I love the way it works. I was developing a project using  
 the Prototype library, but after discovering jQuery I'm converting  
 everything. I'm finding it straightforward but I have a request for  
 a clarification on something.

 I have a function that branches depending on the class name of the  
 element that was passed to it.

 Using Prototype:

 function checkState(id) {
   if ($(id).className == something) { etc

 but in jQuery it doesn't work. It does work if I use:

 if ($(id).attr(class) == something) { etc

 I'm just wondering, as a beginner, if that would be the most  
 'correct' way to do it.

Is id an ID? If so, you could use $('#id.something') and chain  
whatever methods you want onto it.

 Also, if I want to toggle the class name of an element between say  
 active and inactive what is the easiest way to do that? From  
 the documentation I see that addClass won't replace the existing  
 class so it looks like the best way is to use the attr(key,value)  
 method and do something like:

 $(id).attr(class, active)

 It works, I'm just looking for 'best practise' advice.

IYou could do something like this:

   $(id).removeClass('inactive').addClass('active');

and this:

   $(id).removeClass('active').addClass('inactive');

Your approach will strip the id of any other classes that it might  
have as well. So, if the element were div id=foo class=inactive  
pretty, you would be changing it to div id=foo class=active,  
and you would be losing the pretty.

By using .removeClass() and .addClass() you can be a little more  
precise.


 Thanks
 Miles
 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Beginner question re: getting and setting element class name

2007-01-13 Thread Miles Storey

Thanks! I didn't know that existed, I assume it returns boolean. That's
great!

Cheers


On 1/14/07, Mike Alsup [EMAIL PROTECTED] wrote:


 function checkState(id) {
   if ($(id).className == something) { etc

Use the is method:

$(id).is(something);

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Beginner question re: getting and setting element class name

2007-01-13 Thread Miles Storey

On 1/14/07, Karl Swedberg [EMAIL PROTECTED] wrote:




Is id an ID? If so, you could use $('#id.something') and chain
whatever methods you want onto it.



The code that sets the event and function call is:

$(#options).find(a).click(function(){checkState(#+this.id)});

If there's a better way to pass an element reference to a function I'd love
to know, this works but it feels a bit clunky having to append the # like
that.


IYou could do something like this:


   $(id).removeClass('inactive').addClass('active');

and this:

   $(id).removeClass('active').addClass('inactive');

Your approach will strip the id of any other classes that it might
have as well. So, if the element were div id=foo class=inactive
pretty, you would be changing it to div id=foo class=active,
and you would be losing the pretty.

By using .removeClass() and .addClass() you can be a little more
precise.



Thanks, I thought about that, it is probably better practice than the way
I'm doing it using the attr method.

Cheers
Miles
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Beginner question re: getting and setting element class name

2007-01-13 Thread Ⓙⓐⓚⓔ
a bit clunky! just pass in this! and let checkState do the dirty
work... if it is actually needed!

On 1/13/07, Miles Storey [EMAIL PROTECTED] wrote:


 On 1/14/07, Karl Swedberg [EMAIL PROTECTED] wrote:
 
 
  Is id an ID? If so, you could use $('#id.something') and chain
  whatever methods you want onto it.

 The code that sets the event and function call is:

 $(#options).find(a).click(function(){
 checkState(#+this.id)});

 If there's a better way to pass an element reference to a function I'd love
 to know, this works but it feels a bit clunky having to append the # like
 that.

  IYou could do something like this:
 
 $(id).removeClass('inactive').addClass('active');
 
  and this:
 
 $(id).removeClass('active').addClass('inactive');
 
  Your approach will strip the id of any other classes that it might
  have as well. So, if the element were div id=foo class=inactive
  pretty, you would be changing it to div id=foo class=active,
  and you would be losing the pretty.
 
  By using .removeClass() and .addClass() you can be a little more
  precise.

 Thanks, I thought about that, it is probably better practice than the way
 I'm doing it using the attr method.

 Cheers
 Miles

 ___
 jQuery mailing list
 discuss@jquery.com
 http://jquery.com/discuss/





-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/