Multiple $(function () { on one page
I have been searching and searching for this, but I have yet to find anything. I have a jquery function that is loaded in the header of my home page. That header is loaded for every page on my site, and when I visit a page with another $(function () { on it, that pages script doesn't work.
Here is my home page code:
- <script type="text/javascript">
- $(function () {
- $("#basic-combo").sexyCombo();
- $("#basic-combo1").sexyCombo();
- });
- </script>
Below is an example of the second $(function(){ that will not load because of the one in the header.
- <script type="text/javascript">
- window.output = [];
- $(function(){
- $.ajax({
- url: '<?php echo base_url().'jqueryDB/jquery';?>',
- type:'POST',
- async: false,
- dataType: 'json',
- success: function(output_string){
- $("#result").append(output_string['name'][0]);
- output = output_string['name'];
- test();
- }
- });
- });
- </script>
I've tried to change the name of the header function and then do window.load plus along with a few other techniques, but none worked. Does anyone have an idea to what I might need to do?