www.webdeveloper.com
+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695

    Why is this returning a null value???

    Title says it, firebug is pointing me to this section of my code
    Code:
    $(function(){
      // Document is ready
    	$('#sideBarTab').hover( function() { extendContract(); return false; });
    
    });
    There is also a firebug issue that pops up with parsing size, no line is
    mentioned, so I don't know where to point you, all I know is that the
    size issue is somewhere in my php script? Could be an issue, could be
    a non-issue I really can't tell you, if you want I can spit out the error
    codes from the other two browsers I'm testing with which are Chrome
    and Opera.

    Here is the full JS of it so you can peruse it.

    Code:
    var isExtended = 0;
    var width = 200;
    var height = 480;
    var slideDuration = 1000;
    var opacityDuration = 1500;
    
    
    
    function extendContract(){
    
    	if(isExtended == 0){
    		sideBarSlide(0, height, 1, width);
    		sideBarOpacity(0, 1);
    		isExtended = 1;
    		// make expand tab arrow image face left (inwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/(\.[^.]+)$/, '-active$1');
    	}
    	else{
    		sideBarSlide(height, 0, width, 1);
    		sideBarOpacity(1, 0);
    		isExtended = 0;
    		// make expand tab arrow image face right (outwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/-active(\.[^.]+)$/, '$1');
    	}
    
    }
    
    function sideBarSlide(fromHeight, toHeight, fromWidth, toWidth) {
    	$("sideBarContents").css ({'height': fromHeight, 'width': fromWidth});
    	$("#sideBarContents").animate( { 'height': toHeight, 'width': toWidth }, { 'queue': false, 'duration': slideDuration }, "linear" );
    }
    
    function sideBarOpacity(from, to){
    	$("#sideBarContents").animate( { 'opacity': to }, opacityDuration, "linear" );
    }
    
    	
    $(function(){
      // Document is ready
    	$('#sideBarTab').hover( function() { extendContract(); return false; });
    
    });
    And here is the full page it is being implemented in just incase....

    Code:
    <?php
    $hds="layers/";
    $lsr="layers/laser/";
    $led="layers/led/";
    $lit="layers/lighting/";
    $cbl="layers/cable/";
    $css="layers/case/";
    $snd="layers/sound/";
    $trs="layers/truss/";
    $mrr="layers/mirror/";
    $sfx="layers/sfx/";
    $elv="layers/elevator/";
    $ctl="layers/cntrl/";
    $frn="layers/furniture/";
    ?>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    
            <head profile="http://gmpg.org/xfn/11">
    
    <!-- ... Edited out for length .... -->
    
    			<script type="text/javascript" src="js/jquery.js"></script>  
    			<script type="text/javascript" src="js/jquery.cross-slide.js"></script>  
    			<script type="text/javascript" src="js/sidebar.js"></script>
    
    
    	<script type="text/javascript" src="js/prototype.js"></script>
    	<script type="text/javascript" src="js/effects.js"></script>
    	<script type="text/javascript" src="js/accordion.js"></script>
      
    	<script type="text/javascript">
    		//
    		//  In my case I want to load them onload, this is how you do it!
    		// 
    		Event.observe(window, 'load', loadAccordions, false);
    		//
    		//	Set up all accordions
    		//
    		function loadAccordions() {
    			var bottomAccordion = new accordion('vertical_container');
    			
    			var bottomAccordion = new accordion('vertical_container', {
    			  classNames : {
    					toggle : 'vertical_accordion_toggle',
    					toggleActive : 'vertical_accordion_toggle_active',
    					content : 'vertical_accordion_content'
    				}
    			});
    		}
    	</script>
    
    		<script type="text/javascript" src="js/divswap.js"></script>
    		<script type="text/javascript" src="js/lytebox.js"></script>
    			<link rel="stylesheet" href="css/sophos.php" type="text/css" media="screen" />
    			
    	<!-- CSS -->
    	<style type="text/css" >
    		
    <!-- ... Edited out for length .... -->
    
    	</style>
    		</head>
    		
    <body>
    
    <div id="wrapper">
    
    			<script type='text/javascript' id='source-test3'>//<![CDATA[
    			$(function() {
    			$('#test3').crossSlide({
    			  fade: 1
    			}, [
    			  {
    			    src:  'lib/first.jpg',
    			    from: '100% 80% 1x',
    			    to:   '100% 0% 1.7x',
    			    time: 5
    			  }, {
    			    src:  'lib/second.jpg',
    			    from: 'top left',
    			    to:   'bottom right 1.5x',
    			    time: 5
    			  }, {
    			    src:  'lib/third.jpg',
    			    from: 'bottom right',
    			    to:   '80% 80% 1.1x',
    			    time: 2
    			  }, {
    			    src:  'lib/rubber-ring.jpeg',
    			    from: '100% 50%',
    			    to:   '30% 50% 1.5x',
    			    time: 2
    			  }
    			]);
    			});
    			//]]></script>
    
    <div id="sideBar"> 
     
    	<a href="#" id="sideBarTab"><img src="images/main/slide-button.png" alt="sideBar" title="sideBar" /></a> 
     
    	<div id="sideBarContents"> 
    		<div id="sideBarContentsInner"> 
    
    				<br />
    				 
    				<div id="container">
    
    					<div id="vertical_container" >
    
    <!-- ... Edited out for length .... -->
    
    			            <h2 class="accordion_toggle"><b style="color:white">+ </b>Omni Cables</h2>
    							<div class="accordion_content">
    				            <ul>
    				                <li><a href="#" onclick="loadDiv('<? echo $cbl; ?>cbl-al.php','iContent');">All Cables</a></li>
    				            </ul>
    						</div>
    
    				       
    			            <h2 class="accordion_toggle"><b style="color:white">+ </b>Omni Truss</h2>
    							<div class="accordion_content">
    				            <ul>
    				                <li><a href="#" onclick="loadDiv('<? echo $trs; ?>trs-al.php','iContent');">All Cases</a></li>
    				                <li><a href="#" onclick="loadDiv('<? echo $trs; ?>trs-cl.php','iContent');">Clamps</a></li>
    				                <li><a href="#" onclick="loadDiv('<? echo $trs; ?>trs-tr.php','iContent');">Truss</a></li>
    				            </ul>
    						</div>
    										
    				       
    			            <h2 class="accordion_toggle"><b style="color:white">+ </b>Mirror Products</h2>
    							<div class="accordion_content">
    				            <ul>
    				                <li><a href="#" onclick="loadDiv('<? echo $mrr; ?>mrr-al.php','iContent');">All Mirror Products</a></li>
    				            </ul>
    						</div>
    										
    				       
    				</div><!-- ' vertical container ' -->
    
    <!-- ... Edited out for length .... -->
    
    			<script type="text/javascript" >
    
    				var verticalAccordions = $$('.accordion_toggle');
    				verticalAccordions.each(function(accordion) {
    					$(accordion.next(0)).setStyle({
    					  height: '0px'
    					});
    				});
    				
    			</script>
    			
    			
    			</div> <!-- 'container' -->
    			
    	</div> <!-- 'sbInner' -->
    </div> <!-- 'sbContents' -->
     
    </div>  <!-- 'sidebar' -->
    
     <div id="build">
    	<div id="header">
    		<div id="guts"> 
    		
    				<div id="techbar">
    					<a href="javascript:refresh()">home.</a>
    					<a href="#" onclick="loadDiv('<? echo $hds; ?>products','iContent');">products.</a>
    					<a href="#" onclick="loadDiv('<? echo $hds; ?>faq.html','iContent');">faq.</a>
    					<a href="#" onclick="loadDiv('<? echo $hds; ?>manuals.html','iContent');">manuals.</a>
    					<a href="#" onclick="loadDiv('<? echo $hds; ?>tech.html','iContent');">technical.</a>
    					<a href="#" onclick="loadDiv('<? echo $hds; ?>dealer.html','iContent');">dealer center.</a>
    					<a href="#" onclick="loadDiv('<? echo $hds; ?>contact.html','iContent');">contact.</a>
    				</div><!-- "techbar" -->
    			
    			<script language="JavaScript1.2">
    			<!--
    			function refresh()
    			{
    			    window.location.reload( false );
    			}
    			//-->
    			</script>
    			
    			<div name="bodyFRAME" id="iContent" />
    
    					<div id="holder">
    					<!--
    					<div id='test3'>Loading…</div>
    					-->
    					</div>
    						
    <!-- ... Edited out for length .... -->
    
    		</div><!-- 'guts' -->
    
    	 </div><!-- "header" -->
    
    		<div id="footer">
    		<div id="footSpace"></div>
    		<div id="foot_info">
    
    <!-- ... Edited out for length .... -->
    
    		</div><!-- "foot_info" -->
    		</div><!-- "footer" -->
    
     </div><!-- 'build' -->
    </div>
    
    
     
    	</body>
    </html>

  2. #2
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736

  3. #3
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    it looks like $('#sideBarTab') is returning null, I stripped
    js/prototype.js from my index.php and sidebar works, but
    I get an insane amount of errors after its gone. Most
    likely all the functions that are looking for commands
    from prototype.....

    edit / Errors thrown after prototype.js is removed

    Code:
    Prototype is not defined				// Part of prototype	
    http://localhost/xampp/js/effects.js
    Line: 147
    
    Class is not defined					// Part of prototype
    http://localhost/xampp/js/accordion.js
    Line: 19
    
    Event.observe is not a function			// Part of prototype	
    http://localhost/xampp/index.php#
    Line: 42
    
    $$ is undefined						// Part of prototype	
    http://localhost/xampp/index.php#
    Line: 254
    
    handler is undefined					// Part of JQuery
    http://localhost/xampp/js/jquery.js
    Line: 25
    
    $("#sideBarTab").children().get(0).src is undefined //Sidebar still
    http://localhost/xampp/js/sidebar.js
    Line: 16
    Last edited by ehime; 11-21-2008 at 11:31 AM.

  4. #4
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736
    Perhaps a conflict between jQuery and Prototype? Both frameworks define a $() function, and Prototype's version can only take string and DOM nodes as arguments. I believe JQuery allows you to pass a function object, like you are doing, and have it attached to the DOMLoad event. Maybe the version of the $() you are using is that of Prototype and not JQuery?

  5. #5
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    It doesn't like my JQuery thats for sure....
    I got things in "limp home mode" right now
    after ALOT of tweaking, I back dated my
    JQuery pack to 1.2.1 moved my proto js
    files ontop of my jquery, and now I have
    jquery working again, unfortunetly this
    killed anything prototype driven....

    and of course the token error.....

    uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMXPathEvaluator.evaluate]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://localhost/xampp/js/prototype.js :: anonymous :: line 1264" data: no]

  6. #6
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736

  7. #7
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    Quote Originally Posted by toicontien View Post
    Might be of interest: Using jQuery With Other Libraries.
    Thanks toicontien, appreciate the hotlink, you've been helping me
    out a lot lately, if you're ever in Seattle I'm buying you a beer, no
    questions asked.

  8. #8
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736

  9. #9
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    As long as we're on the subject of me owing you favours,
    I was trying the other day to write a snippet into my sidebar.js
    that would take the "current" height of submenucontentsinner
    and constantly replace the value of my var height. Would you
    mind helping a bit with that? I was seriously banging my head
    long after work trying to figure it out, but never got the thing
    working right.... The height of 480 was a max variable that I've
    been having to deal with out of no other method to get my height
    to shrink/grow as I accordion. And even though my accordions
    broken right now (because i suck at jquery ) I should get it
    working here in about an hour or so. Thanks for taking a look dude.

    Code:
    var isExtended = 0;
    var width = 200;
    var height = 480;
    var slideDuration = 1000;
    var opacityDuration = 1500;
    
    
    
    function extendContract(){
    
    	if(isExtended == 0){
    		sideBarSlide(0, height, 1, width);
    		sideBarOpacity(0, 1);
    		isExtended = 1;
    		// make expand tab arrow image face left (inwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/(\.[^.]+)$/, '-active$1');
    	}
    	else{
    		sideBarSlide(height, 0, width, 1);
    		sideBarOpacity(1, 0);
    		isExtended = 0;
    		// make expand tab arrow image face right (outwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/-active(\.[^.]+)$/, '$1');
    	}
    
    }
    
    function sideBarSlide(fromHeight, toHeight, fromWidth, toWidth) {
    	$("sideBarContents").css ({'height': fromHeight, 'width': fromWidth});
    	$("#sideBarContents").animate( { 'height': toHeight, 'width': toWidth }, { 'queue': false, 'duration': slideDuration }, "linear" );
    }
    
    function sideBarOpacity(from, to){
    	$("#sideBarContents").animate( { 'opacity': to }, opacityDuration, "linear" );
    }
    
    	
    $(function(){
      // Document is ready
    	$('#sideBarTab').hover( function() { extendContract(); return false; });
    
    });

  10. #10
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736
    Each DOM node has properties called scrollHeight and scrollWidth. This is the height and width of the content area of a DOM node. The clientHeight and clientWidth is the height and width of the visible portion of the content area. You want to expand to the scrollHeight and scrollWidth of the sideBarContents.
    Code:
    var isExtended = 0;
    //var width = 200; <-- no longer needed
    //var height = 480; <-- no longer needed
    var slideDuration = 1000;
    var opacityDuration = 1500;
    
    
    
    function extendContract(){
    
    	if(isExtended == 0){
    		sideBarSlide(0, sideBarScrollHeight(), 1, sideBarScrollWidth());
    		sideBarOpacity(0, 1);
    		isExtended = 1;
    		// make expand tab arrow image face left (inwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/(\.[^.]+)$/, '-active$1');
    	}
    	else{
    		sideBarSlide(height, 0, width, 1);
    		sideBarOpacity(1, 0);
    		isExtended = 0;
    		// make expand tab arrow image face right (outwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/-active(\.[^.]+)$/, '$1');
    	}
    
    }
    
    function sideBarSlide(fromHeight, toHeight, fromWidth, toWidth) {
    	$("sideBarContents").css ({'height': fromHeight, 'width': fromWidth});
    	$("#sideBarContents").animate( { 'height': toHeight, 'width': toWidth }, { 'queue': false, 'duration': slideDuration }, "linear" );
    }
    
    function sideBarOpacity(from, to){
    	$("#sideBarContents").animate( { 'opacity': to }, opacityDuration, "linear" );
    }
    
    function sideBarScrollHeight() {
    	return $("siteBarContents").scrollHeight;
    }
    
    function sideBarScrollWidth() {
    	return $("siteBarContents").scrollWidth;
    }
    
    	
    $(function(){
      // Document is ready
    	$('#sideBarTab').hover( function() { extendContract(); return false; });
    
    });

  11. #11
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    double posted me, sry
    Last edited by ehime; 11-21-2008 at 01:53 PM.

  12. #12
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    Its doing the same thing it did to me the other day, telling me height is no longer
    defined. JQuery stores its variables in its () though right? Wouldn't I be able to do
    something along the lines of ... ?
    Code:
    function sideBarScrollHeight(height) {
    	return $("siteBarContents").scrollHeight;
    }
    And I caught the error siteBarContents / rly sideBarContents

  13. #13
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736

  14. #14
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    Didn't work either. This is what I think is happening, so bear
    with me for a second. Up in the code height/width are registered as
    variables so expected later on as....variables What I THINK is that
    since no var height or var width is ever declared, or maybe appended
    to(???) in the JQuery that follows that it pretty much freaks out. Is
    there a way to declare height is/as a variable in the code .... just to
    see what it does? I'll try to change sideBarScrollHeight() to height()
    also just to see if I can get it to return a different value to me.

    Code:
    function sideBarScrollHeight() {
    	return $("siteBarContents").scrollHeight;
    }
    Here's the error it returned, I cleaned and marked it with bbcode so
    it doesn't look like mouse sh*t gibberish like it did a minute ago....

    prop[p] is undefined
    (?)()() ...cachedJSFile..... (line 1)
    (?)()() ...cachedJSFile..... (line 1)
    (?)()(Object length=1 0=div#sideBarContents prevObject=Object, function(), undefined) ...cachedJSFile..... (line 1)
    (?)()(function(), undefined) ...cachedJSFile..... (line 1)
    (?)()("fx", function()) ...cachedJSFile..... (line 1)
    (?)()(Object, Object queue=false duration=1000, "linear", undefined) ...cachedJSFile..... (line 1)
    sideBarSlide(0, undefined, 1, undefined)sidebar.js (line 30)
    extendContract()sidebar.js (line 12)
    (?)()()sidebar.js (line 48)
    handleHover() ...cachedJSFile..... (line 1)
    (?)()(mouseover clientX=232, clientY=227) ...cachedJSFile..... (line 1)
    [Break on this error] if (typeof window.jQuery == "undefined") {
    ...cachedJSFile..... (line 1)

    (void 0) is undefined
    handleHover() ...cachedJSFile..... (line 1)
    (?)()(mouseout clientX=230, clientY=245)

    long pause then this one threw.....
    height is not defined
    extendContract()sidebar.js (line 19)
    (?)()()sidebar.js (line 48)
    handleHover(mouseover clientX=231, clientY=252) ...cachedJSFile..... (line 1)
    (?)()(mouseover clientX=231, clientY=252) ...cachedJSFile..... (line 1)
    [Break on this error] sideBarSlide(height, 0, width, 1);

  15. #15
    Join Date
    Feb 2003
    Location
    Chicago Area, IL
    Posts
    5,736
    Did you change this bit of code?
    Code:
    	if(isExtended == 0){
    		sideBarSlide(0, sideBarScrollHeight(), 1, sideBarScrollWidth());
    		sideBarOpacity(0, 1);
    		isExtended = 1;
    		// make expand tab arrow image face left (inwards)
    		$('#sideBarTab').children().get(0).src = $('#sideBarTab').children().get(0).src.replace(/(\.[^.]+)$/, '-active$1');
    	}
    The height and width variables shouldn't be used anymore.

    (sorry for the text size. bold text hides easily in the code boxes)
    Last edited by toicontien; 11-21-2008 at 03:10 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



Recent Articles