CodeIgniter Forums
My js code from template runs two tiems - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: My js code from template runs two tiems (/showthread.php?tid=48658)



My js code from template runs two tiems - El Forum - 01-24-2012

[eluser]Dominiq[/eluser]
Hey I have problem with my js code that is in CI template. He runs two times instead of one time. This is my test example:
Code:
[removed]
$(document).ready(function() {
console.log('php');
});
[removed]
In firebug console I see this:
Code:
>js
>php
>php
"js" is log from my js file. I was checking what will be executed first.

This part of js code is in template that is returned as a string:
Code:
$string = $this->load->view('myfile', '', true);
Then this $string is printed by echo in another template that is sent directly to browser:
Code:
$this->load->view('blogview', $data);

I don't have idea why it is like this. Maybe because template in template? Or because that I did retuned first template as string?


My js code from template runs two tiems - El Forum - 01-24-2012

[eluser]Dominiq[/eluser]
Problem solved. I did buy template from theme forest. I did look that they are getting one atribute and put in in other via js.
Post closed.