Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Probleme mit Javascript Dateien in einem Template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
fabi1986
Smarty n00b


Joined: 24 Mar 2012
Posts: 4

PostPosted: Sat Mar 24, 2012 10:53 pm    Post subject: Probleme mit Javascript Dateien in einem Template Reply with quote

Hallo zusammen,
ich habe eine .tpl Datei, in dieser rufe ich
Code:

<script type="text/javascript" src="js/sites/news/news.js"></script>

auf, wenn ich jetzt aber z.B mehrmals auf den Menüpunkt "News" klicke wird die news.js jedes mal neu geladen, mit einer neuen ID

http://site/js/sites/news/news.js?_=1332628161509
http://site/js/sites/news/news.js?_=1332628164939
http://site/js/sites/news/news.js?_=1332628168843
http://site/js/sites/news/news.js?_=1332628177685
...

also es wird nicht die selbe aus dem cache genommen.
Ich hoffe ihr könnt mir Helfen.
Vielen Dank
Grüße Fabi
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Mar 24, 2012 11:31 pm    Post subject: Reply with quote

javascript läuft auf dem client im Browser. Das heißt der Output von news.js ist nicht in Smarty's cache.
Back to top
View user's profile Send private message
fabi1986
Smarty n00b


Joined: 24 Mar 2012
Posts: 4

PostPosted: Mon Mar 26, 2012 3:59 pm    Post subject: Reply with quote

das problem ist aber das smarty da immer eine neue Zahl hinter das ? macht, wie kann ich das vermeiden?
Back to top
View user's profile Send private message
fabi1986
Smarty n00b


Joined: 24 Mar 2012
Posts: 4

PostPosted: Mon Mar 26, 2012 7:57 pm    Post subject: Reply with quote

ok das problem liegt nicht an smarty sondern an ajax
Back to top
View user's profile Send private message
fabi1986
Smarty n00b


Joined: 24 Mar 2012
Posts: 4

PostPosted: Tue Mar 27, 2012 4:17 pm    Post subject: Reply with quote

habe das Problem jetzt gelöst, falls noch jemand das selbe Problem hat hier die Lösung:
Code:

$.ajaxSetup({ cache: true });
         $.ajax({
            url : "index.php"+url,
            type : "POST",
            cache : true,
            dataType : "html",
            data : "LoadContent=true",
            success : function(data) {
   
               $("#loaded_content").html(data);
               $("#loaded_content").css('visibility','');
            }
         });

und zwar muss man mit $.ajaxSetup({ cache: true }); den cache aktivieren nur so wird keine timestamp an die .js Datei gehängt

Grüße Fabi
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German 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