Bonjour,
Je suis en train de tester Jquery avec Rails, pour l’instant ça va à
peu près mais j’ai un problème avec du javascript (googlemaps) qui
fonctionnait avec et qui ne fonctionne plus maintenant.
mon application.js est comme suit (pas besoin de tout lire, la partie
dans $(function) marche
$(function() {
var delete_url = "";
$("#dialog-confirm-delete").dialog({
resizable: false,
height:140,
modal: true,
autoOpen: false,
title: 'Suppression d\'un élément',
buttons: {
Oui: function() {
$('<form method="post" action="' + delete_url + '" /
‘)
.append(’‘)
.append(’')
.appendTo(‘body’)
.submit();
$(this).dialog(‘close’);
},
Non: function() {
$(this).dialog(‘close’);
}
}
});
$(".delete").click(function() {
delete_url = $(this).attr("href");
$("#dialog-confirm-delete").dialog('open');
return false;
});
// Cluetip
$(‘input.tooltip’).cluetip({splitTitle: ‘|’, arrows: true});
// prettyPhoto
$("a[rel^='prettyPhoto']").prettyPhoto({
theme: 'facebook',
autoplay: true
});
});
LocationMap = new Class.create({
initialize: function(map, location, zoom) {
this.element = $(map);
this.location = location.evalJSON();
this.zoom = zoom
document.observe(“dom:loaded”, this.init.bind(this));
},
init: function() {
if (GBrowserIsCompatible()) {
// Create a google map
this.map = new GMap2(this.element);
// Add controls
this.map.addControl(new GLargeMapControl());
this.map.addControl(new GMapTypeControl());
// Center on location
this.map.setCenter(new GLatLng(this.location.location.lat,
this.location.location.lng), this.zoom);
// this.map.setCenter(new GLatLng(48.8640722000,
2.3677068000), 15);
var marker = new GMarker(new GLatLng
(this.location.location.lat, this.location.location.lng));
this.map.addOverlay(marker);
}
}
});
et dans ma vue j’ai
<%= javascript_tag “new LocationMap(‘map’,‘#{@location.to_json(:only
=> [:name, :lat, :lng])}’,#{@zoom});” %>
J’obtiens l’erreur
LocationMap is not defined
new LocationMap(‘map’,‘{“location”: {"…7111702, “lat”:
48.6850566941}}’,16);
A noter que j’ai installé le jrail plugin et que j’ai essayé de
remonter le LocationMap dans le $(function) mais sans succès.
Merci de m’avoir lu jusqu’ici, merci de votre aide.