[jQuery] Set height problem
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2>Sanyi, "this" is not the same when you're inside a nested
function.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2>Add this line of code at the beginning of
showFlash:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2> var self = this;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2>And then change "this" to "self", and you'll be in
business. (You can use any variable name instead of "self"; that's just a common
choice.)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2>Also, since you're using $('#'+self.actualTab) and
$('#comment-flash') more than once each, it's not a bad idea to save a reference
to each, e.g.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2> var $tab =
$('#'+self.actualTab);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=773153808-12102006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana><FONT size=2><FONT
color=#0000ff><SPAN class=773153808-12102006>And then use $tab in place of the
full $() call each time. Ditto for the comment-flash.</SPAN> <SPAN
class=773153808-12102006>In this particular piece of code, it may not make much
difference, but it's a really good habit to get into for those cases where it
does speed up performance.</SPAN></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Verdana><FONT size=2><FONT
color=#0000ff><SPAN
class=773153808-12102006></SPAN></FONT></FONT></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Verdana><FONT size=2><FONT
color=#0000ff><SPAN
class=773153808-12102006>-Mike</SPAN></FONT></FONT></FONT></DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com] <B>On Behalf Of </B>Sanyi<BR><B>Sent:</B>
Thursday, October 12, 2006 1:23 AM<BR><B>To:</B>
discuss@jquery.com<BR><B>Subject:</B> [jQuery] Set height
problem<BR></FONT><BR></DIV>
<DIV></DIV>Hi All,<BR><BR>I have strange problem in this function I
wrote:<BR><BR><BR>1: function showFlash(text) {<BR>2:
this.addFlash(text);<BR>3: <BR>4:
$('#'+this.actualTab).height('265px');<BR>5: <BR>6: if
(this.Flash != '') $('#comment-flash').animate(<BR>7:
{opacity: 'show'},<BR>8:
1500,<BR>9: function() {<BR>10:
$('#'+this.actualTab).height('290px');<BR>11:
$('#comment-flash').hide();<BR>12:
} <BR>13: );<BR>14:}<BR><BR>on line 4 the
height has been given and can be shown, but on line 10 setting the height
doesn't seemed to work. Is there anything I missed? I am newby to
jQuery.<BR><BR>you can test it under following URL: <A
href="http://mkmcom.hu/test2/index.html">http://mkmcom.hu/test2/index.html</A><BR><BR>Thx<BR>Alex<BR></BLOCKQUOTE></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/