Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Colocar função tpl dentro do javascript

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: Portuguese
View previous topic :: View next topic  
Author Message
terra
Smarty Rookie


Joined: 27 Jul 2011
Posts: 26

PostPosted: Mon Apr 07, 2014 10:23 pm    Post subject: Colocar função tpl dentro do javascript Reply with quote

Olá,

preciso fazer isso mas não funciona

Code:


{literal}<style type="text/css">
 body { font: normal 10pt Helvetica, Arial; }
 #map { width: 350px; height: 300px; border: 0px; padding: 0px; }
 </style>
 <script src="http://maps.google.com/maps/api/js?v=3&key=&sensor=true" type="text/javascript"></script>
 
 <script type="text/javascript">
 //Sample code written by August Li
 var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.png",
 new google.maps.Size(32, 32), new google.maps.Point(0, 0),
 new google.maps.Point(16, 32));
 var center = null;
 var map = null;
 var currentPopup;
 var bounds = new google.maps.LatLngBounds();
 function addMarker(lat, lng, info) {
 var pt = new google.maps.LatLng(lat, lng);
 bounds.extend(pt);
 var marker = new google.maps.Marker({
 position: pt,
 icon: icon,
 map: map
 });
 var popup = new google.maps.InfoWindow({
 content: info,
 maxWidth: 300
 });
 google.maps.event.addListener(marker, "click", function() {
 if (currentPopup != null) {
 currentPopup.close();
 currentPopup = null;
 }
 popup.open(map, marker);
 currentPopup = popup;
 });
 google.maps.event.addListener(popup, "closeclick", function() {
 map.panTo(center);
 currentPopup = null;
 });
 }
 function initMap() {
 map = new google.maps.Map(document.getElementById("map"), {
 center: new google.maps.LatLng(0, 0),
 zoom: 14,
 mapTypeId: google.maps.MapTypeId.ROADMAP,
 mapTypeControl: false,
 mapTypeControlOptions: {
 style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
 },
 navigationControl: true,
 navigationControlOptions: {
 style: google.maps.NavigationControlStyle.SMALL
 }
 });


 [b]{foreach from=$var_list item=i}
("addMarker({$i.x}, {$i.y},'<b>{$i.bizname}</b><br/>{$i.add1}');\n");
 
 {/foreach}[/b]

 center = bounds.getCenter();
 map.fitBounds(bounds);
 
 }
 </script>
{/literal}



alguem pode me ajudar?

valeu
Back to top
View user's profile Send private message
migas
Smarty Regular


Joined: 07 Apr 2004
Posts: 73
Location: Porto, Portugal

PostPosted: Fri Jun 12, 2015 10:41 am    Post subject: Reply with quote

Tens o código smarty dentro do LITERAL pelo que deixa de ser compilado.


Code:
{/literal}
 [b]{foreach from=$var_list item=i}
("addMarker({$i.x}, {$i.y},'<b>{$i.bizname}</b><br/>{$i.add1}');\n");
{literal}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: Portuguese All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP