I'm using Code Igniter and the Googlemaps library. This library generates a lot of Javascript code dynamically, including the contents of the InfoWindows for each new marker, but I'd like to keep that in a separate template file, like a regular View.
I have this Javascript code (from Googlemaps' library):
var lat = marker.getPosition().lat();
var long = marker.getPosition().lng();
var windowContent = "";
if( _new ) {
var newIW = new google.maps.InfoWindow( { content: windowContent } );
What I want to do is to load windowContent
from a template file. I have already succeeded in dynamically generating a form for this variable and using lat
and long
variables defined just above, but how can I achieve this in Code Igniter? I can't use load->view
because I'm not in a Controller's context. And I cannot use include()
or readfile()
either because of CI's security constraints.
Any hints?
var newIW = new google.maps.InfoWindow( { content: windowContent } );
is the initialization code. As ajax is an async process you would only be able to execute the code once the ajax call has returned with the content.