Reputation: 1075
My index file contains layout code that doesn't change on any page. Where the content of the page is displayed, i used GET vars to determine which php file to include. Whenever I put in a jquery date picker (http://jqueryui.com/datepicker/), the $("ID_Name").datepicker(); call doesn't execute.
Here's what I'm doing: ./index.php ./pages/createJob.php ./pages/dealerships.php
So the user is loading index first, then createJob.php, which then calls dealerships.php.
I have the following in the head of index.php:
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
I then have this in dealerships.php:
<script>
$(document).ready(function() {
alert('foo');
$(function() {
$("#dealershipSaleStartDate").datepicker();
});
alert('bar');
});
</script>
<input id="dealershipSaleStartDate" type="text" />
When the page loads, i get the "foo" alert, but not the "bar" alert. Can I not reference a function that's not explicitly in the specific file? Doesn't seem right, but it's the only thing I can think of...
Upvotes: 0
Views: 1580
Reputation: 36531
you don't need two doumnet.ready function there..remove one
<script>
//$(document).ready(function() {
//alert('foo');
$(function() { //<--this is shorthand of document.ready function
alert('bar');
$("#dealershipSaleStartDate").datepicker();
});
//});
</script>
Upvotes: 1