I'm working on a CodeIgniter application.
I have a view, let's call it Calendar, which has a JS/jQuery <script>
block in it. Looks like this:
$(document).ready(function() {
$(#day_list).fadeIn(600);
// init
var current_month = <?= $init['current_month']; ?>;
var current_year = <?= $init['current_year'] ?>;
// previous, next month ajax call
$(.previous, .next).click(function(event) {
// do stuff to these variables, then ajax call.
$.ajax({
// ajax
});
});
});
In another view, my footer, I have another script block which should use the same variables (current_month and current_year). However, it doesn't know about their existence. What would be the quickest, and easiest, way to pass these variables from the first <script>
block to the other? I can't put the two blocks together because of the way my application is build. Should I just write a function for it which gets and returns these values (and how should I do this? I'm such a newbie) or is there an easier way?
Thanks a lot!