Quick links: Content - sections - sub sections
EN FR
Quick Search Advanced search
 
Page

  [Opened] Comment appeller j_basepath dans un fichier javascript ?

Posted by pheromix on 04/15/2016 13:04

J'ai un fichier javascript (.js). J'aimerai référencer une image dans ce fichier ; donc je dois référencer la variable Jelix j_basepath ! Par exemple :

ajoutPrevImage.attr ("src", "{$j_basepath}srcs/www/design/images/icons/arrow_left.gif");

Comment faire ?

  [Opened] Comment appeller j_basepath dans un fichier javascript ?

Reply #1 Posted by laurentj on 04/15/2016 15:09

Bonjour,

dans ton template principal, ou via l'objet reponse et sa méthode addJSCode(), tu peux ajouter la déclaration d'une variable JS qui contiendrait la valeur de $j_basepath (qui équivaut à jApp->urlBasePath()), et utiliser cette variable dans ton fichier js.

  [Opened] Comment appeller j_basepath dans un fichier javascript ?

Reply #2 Posted by pheromix on 04/15/2016 16:04

ce fichier javascript sera utilisé par toutes les templates contenant une liste , pour afficher les boutons de navigation "précédent" et "suivant". Donc comment faire ? Pourriez-vous donner un code snippet ?

 
Page
  1. Pourquoi une vieille version de TCPDF avec Jelix ? >
  2. SoapFault exception: [Client] DTD are not supported by SOAP >
  3. SoapFault exception: [Client] DTD are not supported by SOAP >
  4. SoapFault exception: [Client] DTD are not supported by SOAP >
  5. Re: [Résolu] Méthode protégée ou private dans un contrôleur >
  6. jClasses::getService me renvoie le code source du fichier >
  7. générer une erreur au format jResponseJsonRpc Jelix 1.3 >
  8. Comment appeller j_basepath dans un fichier javascript ?