3217 Posts in 853 Topics by 812 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1879 Views |
-
unable to call Inline Javascript in Template file

26 November 2009 at 7:37pm
Hi ,
I am unable to call the javascript script in template file while using ajax functionality. please find the code below
DemoPage.php
function DemoContent()
{
/*$records = DataObject::get( "ProductMainPage", "", "", "", "");*/
$records = DataObject::get( "DemoPage", "ParentID = $this->ID", "", "", "");
return $this->customise(array(
'DemoMainPage' => $records
))->renderWith('DemoContent');
}DemoContent.ss
<script>
function samplefunction()
{
........
}</script>
<div>
[demo value]
</div>
http://localhost/myproject/demo-page/DemoContent - unable call the javascript inside the render template file. please do needful . let me know if you need any clarification.
Regards,
thisIsRam -
Re: unable to call Inline Javascript in Template file

27 November 2009 at 2:11am
I solved this by creating a seperate template file and render it as javascript like this:
class MyPage_Controller extends Page_Controller {
function googlemapjs(){
SSViewer::set_source_file_comments(false);
ContentNegotiator::disable();
$this->getResponse()->addHeader('Content-Type', 'text/javascript; charset="utf-8"');
return $this->renderWith("GoogleMapJS");
}I created a file in the templates folder called GoogleMapJS.ss with the javascript code and call it from another template with:
<script src="$URLSegment/googlemapjs" type="text/javascript"></script>
In this way I could use a dynamic variable to call XML file in the same way with data from an Object that contains the Address data.
Hope it helps.
-
Re: unable to call Inline Javascript in Template file

28 November 2009 at 12:08am Last edited: 28 November 2009 12:09am
Hi martiji,
Thanks for your reply,
I got some answer from you. it will use for dynamic script call from globally and act like separate script file.
but still i get suffer to call the script in template file. because while calling Ajax script ,
any possible to call inline JavaScript in render template file or to combine both JavaScript and normal ss template in one render file
else any other possible way to clear the issue. For example
<script src="$URLSegment/googlemapjs" type="text/JavaScript"></script>
DemoPage.php
function DemoContent()
{
/*$records = DataObject::get( "ProductMainPage", "", "", "", "");*/
$records = DataObject::get( "DemoPage", "ParentID = $this->ID", "", "", "");
return $this->customise(array(
'DemoMainPage' => $records
))->renderWith('DemoContent');
}DemoContent.ss
<script src="$URLSegment/googlemapjs" type="text/javascript"></script>
<div>
[demo value]
</div>Regards,
thisIsRam
Ahsan Technologies (Pvt) Ltd,
www.agriya.com,www.anova.tv,www.isocial.in,www.markit.me
| 1879 Views | ||
|
Page:
1
|
Go to Top |


