Bevor wir mit einem Modal anfangen, sollten wir auf das prompt verzichten und statt dessen ein Input-Felder verwenden:
<form>
<label>
Attributwert Attribut1 ändern:
<input class="attrinput" type="text">
<input class="okbutton" type="button" value="Abschicken" data-deviceid="deviceid1" data-attributeid="attributeId1">
</label>
<label>
Attributwert Attribut2 ändern:
<input class="attrinput" type="text">
<input class="okbutton" type="button" value="Abschicken" data-deviceid="deviceid2" data-attributeid="attributeId2">
</label>
</form>
<script>
jQuery(".okbutton").on("click", function () {
var deviceId = $(this).data("deviceid"),
attributeId = $(this).data("attributeid"),
newValue = $(this).prev(".attrinput").val();
console.log("clicked", deviceId, attributeId, newValue
);
if (newValue != null) {
jQuery.get('rest/devices/' + deviceId,
+ '/attributes/' + attributeId
+ '/valueText?set=' + newValue);
}
});
</script>
Alles anzeigen
Erst Mal um zu testen, ob es damit funktioniert. console.log ist für mich zum Testen, jQuery.get konnte ich verständlicher Weise nicht testen.