Welcome Guest, Not a member yet? Register   Sign In
Including external js not working...
#1

[eluser]rich.a.coy[/eluser]
Hello,

I'm building a semi large app that will be using jQuery. In my header view I have a link to the jQuery file and it works just fine:

<i>I intentionally miss-spelled script in the tags below so they would not get striped out in the forum. In the real file they are correct.</i>

Code:
<scriipt type="text/JavaScript" src="js/jquery-1.3.2.min.js"></scriipt>


Right under that I have a link to an external js file that I wrote to keep my view clean:

Code:
<scriipt type="text/JavaScript" src="js/includes/home.js"></scriipt>

When I view source in firefox the link is there and if I click on it the js file is there. However the javascript does not work. I removed the opening and closing script tags in the js file. If I copy and paste the javascript in to the header file (between script tags) it works. Is there something I'm missing?

My home.js jQuery script is pretty basic:

Code:
$function() {    
       $("#request").focus(function() {
           $(this).animate({height: '100px' }, 1000);
           $("#form_controls").animate({ opacity: 'toggle', height: 'toggle' });
           return false;
       });

I tried adding document ready to the function and it made no difference.

Do I need to modify the script when it's called remotely? Any thoughts? Thanks.
#2

[eluser]flaky[/eluser]
are you debugging with firebug?
#3

[eluser]rich.a.coy[/eluser]
Thanks for the reminder about firebug! I was missing a closing }. Do I need to wrap everything in document ready if it's being brought from an external file? It only works with that, but when it was internal js it did not require it.

Thanks again.
#4

[eluser]flaky[/eluser]
it is a better practice if you use
Code:
$(document).ready(function(){
.
.




Theme © iAndrew 2016 - Forum software by © MyBB