Re: [Proto-Scripty] TypeError: $(...) is null

2012-12-19 Thread Walter Lee Davis
You can fix this two different ways: either move your script block to the 
bottom of the page (just before /body, as in my example) or add an unobtrusive 
listener block around your main function. The issue here is that because your 
script appears before the HTML it applies to, none of the elements are present 
in the DOM yet when the closure tries to wrap around them. 

Here's how to wrap them (if you want to put the script at the top of the page:


document.observe('dom:loaded', function(){
var toggles = $$('.toggle'). [etc...]
});


Walter

On Dec 19, 2012, at 8:13 AM, tab1ta wrote:

> Taking from an example that works:
> 
> 
> 
> 
> 
> Show-Hide Divs
>  src="http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js";>
> [snip]

>   toggles = $$('.toggle').invoke('hide');
> })
>   
> 
> 
> 
> I tried to apply this script to a complete webpage but i trows me an error 
> TypeError the $('') function considers the id i pass to it as a null. My web 
> page is longer.
> 
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> 
> 
> @import url(styles.css);
> 
>   
>src="http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js";>
>   

[Proto-Scripty] TypeError: $(...) is null

2012-12-19 Thread tab1ta
Taking from an example that works:





Show-Hide Divs
http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js";>

 .toggle {
   padding: 0;
   margin-left: 1em;
   background-color: #989699;
   border: 2px solid #1f0c00;
   float: left;
   opacity:0.7;
 }
 #menu {
   float: left;
 }




 
   One
   Two
   Three
   Four
   Five
   Six
 

  
   © by flicr.comhttp://tinyurl.com/cwtt2yq";>See 
Photo
  
  
   © by flicr.comhttp://tinyurl.com/cwtt2yq";>See 
Photo
  
  
   © by flicr.comhttp://tinyurl.com/cwtt2yq";>See 
Photo
  
  
   © by flicr.comhttp://tinyurl.com/cwtt2yq";>See 
Photo
  
  
   © by flicr.comhttp://tinyurl.com/cwtt2yq";>See 
Photo
  
  
   © by flicr.comhttp://tinyurl.com/cwtt2yq";>See 
Photo
  
  
var toggles = $$('.toggle').invoke('hide');
$('menu').on('mouseover', 'a', function(evt, elm){
  evt.stop();
  toggles.invoke('hide');
  $(elm.href.split('#').last()).show();
});
$('menu').on('mouseout', 'a', function(evt, elm){
  evt.stop();
  toggles.invoke('show');
  $(elm.href.split('#').last()).hide();
   toggles = $$('.toggle').invoke('hide');
})
  



I tried to apply this script to a complete webpage but i trows me an error 
TypeError the $('') function considers the id i pass to it as a null. My 
web page is longer.

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">@import url(styles.css);http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js 
http://ajax.googleapis.com/ajax/libs/prototype/1.7/prototype.js>">
 
   var toggles = $$('.toggle').invoke('hide');  
   $('gallery').on('mouseover', 'a', 
function(evt, elm){   
evt.stop();   
toggles.invoke('hide'); 
$(elm.href.split('#').last()).show();   
  });   
  $('gallery').on('mouseout', 'a', function(evt, elm){  
evt.stop(); 
toggles.invoke('show'); 
$(elm.href.split('#').last()).hide();   
toggles = 
$$('.toggle').invoke('hide');   
});  Python Speculative 
Interface   

 http://localhost/py/index.php?tabindex=0>">Concept 

   http://localhost/py/index.php?tabindex=1>">Wiki
  
  http://localhost/py/images/psi.png>" />  
  http://joy.indivia.net/py/cgi-bin/OOpoetry.cgi 
http://joy.indivia.net/py/cgi-bin/OOpoetry.cgi>" method="get"> 
   Python from a theoretical point of 
view  This interface aims to show and 
explain some communicative and theoretical aspects inscribed in the mechanisms 
behind a programming language. The programming language named Python is useful 
to achieve this goal as it provides an interpreter but it can even run source 
code as object code. If you search for a 
command of the python programming language in the form below you will get the 
description of the logical and communicative process executed by it in the 
machine. The explanation can be of a logical, mathematical or semiological 
nature. This is an attempt to enhance python programming language as a 
signifying language, which can execute not only algebrical processes but even 
what could be defined as meaning. 
       
  
 http://localhost/py/index.php#thing_1>">http://localhost/py/images/gallery1.jpg.jpg>"/>   
   http://localhost/py/index.php#thing_2>">http://localhost/py/images/3188832812_573db43c7d.jpg>"/>