Skip to content

Instantly share code, notes, and snippets.

@haeky
Last active December 18, 2015 03:58
Show Gist options
  • Save haeky/5721630 to your computer and use it in GitHub Desktop.
Save haeky/5721630 to your computer and use it in GitHub Desktop.
Example Ajax from AltitudeHardware with Play! Framework 1.2.5
var actionDevices: #{jsAction @WebAPI.devices(":typeId")/},
$.ajax({
url: actionDevices({
typeId: id
}),
dataType: 'json',
success: function(result) {
$(".deviceList ul").empty();
$.each(result, function(i,value) {
$("#hardwareList li.active")
.append($("<ul/>", {"class" : "nav nav-list"})
.append($("<li/>", {"class": "draggable"})
.append($("<input/>",{"type" : "hidden"}).val(value.connectors.length > 0 ? value.connectors[0].name : ""))
.append($("<span/>", {"class" : "label label-info"}).text(value.name).attr("onClick","altitude.hardware.showAttribute('" + value.id + "')"))
.append($("<input/>",{"type" : "hidden"}).val(value.id))
)
);
});
$(".draggable").draggable({ helper: "clone" });
activateDroppable();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment