我有类似的东西:
<div id="list_event" class="row">
<div class="panel panel-primary filterable">
<div class="panel-heading">
<h3 class="panel-title">Evénements</h3>
<div class="pull-right" style="margin-top:-6px">
<span class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</span>
</div>
</div>
<table class="table table-hover table-striped table-bordered" id="table_event">
<thead>
<tr class="filters">
<th><input type="text" class="form-control" placeholder="Titre" disabled></th>
<th><input type="text" class="form-control" placeholder="Description" disabled></th>
<th><input type="text" class="form-control" placeholder="Date de début" disabled></th>
<th><input type="text" class="form-control" placeholder="Date de fin" disabled></th>
<th><input type="text" class="form-control" placeholder="Type" disabled></th>
<th><input type="text" class="form-control" placeholder="Lieu" disabled></th>
<th>Type d'alerte</th>
<th>Statut</th>
<th style="display:none">#</th>
<th class="tabledit-toolbox-column"></th>
</tr>
</thead>
<tbody>
<% for(var i=0; i<listEvent.length; i++) {%>
<tr>
<td class="tabledit-view-mode"><span class="tabledit-span"><%- listEvent[i].title %></span><input class="tabledit-input form-control input-sm" type="text" name="title" value="<%- listEvent[i].title %>" style="display: none;" disabled=""></td>
<td class="tabledit-view-mode"><span class="tabledit-span"><%- listEvent[i].description %></span><input class="tabledit-input form-control input-sm" type="text" name="description" value="<%- listEvent[i].description %>" style="display: none;" disabled=""></td>
<td class="tabledit-view-mode"><span class="tabledit-span"><%- listEvent[i].startDate %></span><input class="tabledit-input form-control input-sm" type="text" name="startDate" value="<%- listEvent[i].startDate %>" style="display: none;" disabled=""></td>
<td class="tabledit-view-mode"><span class="tabledit-span"><%- listEvent[i].endDate %></span><input class="tabledit-input form-control input-sm" type="text" name="endDate" value="<%- listEvent[i].endDate %>" style="display: none;" disabled=""></td>
<td class="tabledit-view-mode"><span class="tabledit-span"><%- listEvent[i].type %></span><input class="tabledit-input form-control input-sm" type="text" name="type" value="<%- listEvent[i].type %>" style="display: none;" disabled=""></td>
<td class="place"><%- listEvent[i].place %></td>
<td>
<ul>
<% for(var j=0; j<listEvent[i].typesAlert.length; j++) {%>
<li><%- listEvent[i].typesAlert[j].name %></li>
<% } %>
</ul>
</td>
<td>
<%
if (listEvent[i].state == 1) {%>
<span class="label label-warning">En cours</span>
<%}
if (listEvent[i].state == 2) {%>
<span class="label label-success">Validé</span>
<%}
if (listEvent[i].state == 3) {%>
<span class="label label-danger">Bloqué</span>
<%}%>
</td>
<td scope="row" style="display:none"><%- listEvent[i].id %></td>
<td style="white-space: nowrap; width: 1px;">
<div class="tabledit-toolbox" style="margin-left: -5px; text-align: right;">
</div>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
var geocoder;
$(function geocode (){
geocoder = new google.maps.Geocoder();
var coordinates = document.getElementsByClassName("place");
for (var i=0; i<coordinates.length; i++) {
coordinates[i].id = coordinates[i].innerHTML;
retrieveAddress(coordinates[i], coordinates[i].innerHTML);
}
});
function retrieveAddress(coordinate, input) {
var latlngStr = input.split(";",2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK && results[0]) {
coordinate.innerHTML = results[0].formatted_address;
}
});
}
</script>
<script src="/js/jquery.tabledit.js"></script>
<script type="text/javascript">
$('#table_event').Tabledit({
url: '/event/tableEdit',
columns: {
identifier: [7, 'id'],
editable: [[0, 'title'],[1, 'description'],[2, 'startDate'],[3, 'endDate'],[4, 'type']]
},
buttons: {
edit: {
class: 'tabledit-edit-button btn btn-sm btn-warning',
html: '<span class="glyphicon glyphicon-edit"></span>',
action: 'edit'
},
delete: {
class:'tabledit-remove-button btn btn-sm btn-danger tabledit-confirm',
action: 'delete'
},
confirm: {
class: 'btn btn-sm btn-danger',
html: '<span class="glyphicon glyphicon-remove"></span> Supprimer'
},
restore: {
class: 'btn btn-sm btn-warning',
html: '<span class="glyphicon glyphicon-cloud-download"></span> Restaurer',
action: 'restore'
},
save: {
class: 'btn btn-sm btn-success',
html: '<span class="glyphicon glyphicon-ok"></span> Sauvegarder'
},
},
});
</script>
问题是函数地理编码仅适用于前五行而其余部分未被调用(我的地理编码功能允许从点位置获取可读地址或地名(纬度,经度) )) this is the result