It's like referencing a variable. Until the div, the variable is not
available so the function is looking for a variable that does not exist
In lasso land like using $ before the variable is created.
Deco
On Jul 9, 2007, at 10:39 AM, BeeRich wrote:
>
>
>
> On Jul 9, 10:58 am, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> Hey there, one thing I would like to ask is that you have as the
>> observed element as 'iframe1', to clarify this isn't an iframe
>> right,
>> which might cause problems.
>
> Sorry, my ISP is up and down like a bus station toilet seat today.
>
> I will post the current test file I've made up, which replicates what
> I did in ... an earlier test:
>
> <script language="Javascript" type="text/javascript">
>
> Event.observe('iframe1', 'load', changediv ());
>
> function changediv () {
> // alert('OK SHE IS WORKING');
> $('imageShow1').update('OK SHE IS WORKING');
> }
>
> </script>
>
> <safety: IFRAME tag removed>
> enctype="multipart/form-data" frameborder="2">
> Sorry, your browser does not support this technology...please use
> Safari or Firefox
> </iframe>
>
> <a href="#" onclick="javascript:changediv(); return false;">CHANGE
> DIV</a><br/><br/>
>
> <div id="imageShow1">down here</div>
>
>
>> The alert works because it is simply a string, and doesn't return an
>> object, so you need to use alert($(imageShow1));
>>
>> if it cannot find it may be because your script is located before the
>> element, and the script needs placing further down your document, so
>> it can use these elements
>
> OK, I moved the script below the target div, and she worked! Can you
> explain that one to me again? The elements in question have to be
> "declared" in the normal html BEFORE the JS can make functions
> operable? Is this correct? If so, is this theoretically backwards to
> what middleware devs would usually expect?
>
> It worked on my other example too. So that is it. Many thanks, but
> could you inform me as to why this needs to be lower than the
> elements?
>
> Cheers
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---