Hi guys,
I've developed a "Google-Maps-like" user interface for my intranet where users can add steps to calculated routes and distances. I'm using sortable div
s to reorder steps. Now I want to remove steps, but my JavaScript/jQuery code doesn't work at all. Can you help me?
My jQuery code:
$(document).ready(function() {
$("#sortable").sortable();
$("#sortable").disableSelection();
});
function addStep() {
var temp = $('.template').clone();
$(temp).removeClass("template");
$(temp).addClass("sort");
$('#sortable').append(temp);
}
function removeStep() {
$(this).closest('div.sort').remove();
$("#sortable").sortable('refresh');
}
And my HTML:
//template to add new step
<div class="template">
<input type="text" name="addressN" value="" class="address" />
<input type="button" class="remove" value="Remove" onclick="removeStep();" />
</div>
//sortable list of step
<div id="sortable">
<div class="sort">
<input type="text" name="Start" value="" class="address" />
</div>
<div class="sort">
<input type="text" name="End" value="" class="address" />
</div>
</div>
<input type="submit" value="Get Route!" onclick="showLocation(); return false;" />
<input type="submit" value="Add Step" onclick="addStep(); return false;" />
Thanks in advance!