You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.6 KiB
45 lines
1.6 KiB
<script>
|
|
function update(url, parent, targetId) {
|
|
$(targetId).find('option').not('[value=""]').remove();
|
|
if (url != null) {
|
|
url += '?parentId=' + encodeURI(parent);
|
|
$.getJSON(url, function (data) {
|
|
$.each(data, function (i, v) {
|
|
$(targetId).append('<option value="' + v.Value + '">' + v.Text + '</option>');
|
|
});
|
|
});
|
|
}
|
|
}
|
|
function reset() {
|
|
$('form').removeData('validator');
|
|
$('form').removeData('unobtrusiveValidation');
|
|
$.validator.unobtrusive.parse('form');
|
|
}
|
|
</script>
|
|
<script>
|
|
$(function () {
|
|
$('#NodeId').change(function () {
|
|
var id = $(this).find(':selected').val();
|
|
update('@Url.Action("GetSenceJson", "Ajax")', id, "#SenceId");
|
|
update('@Url.Action("GetDeviceJson", "Ajax")', id, "#DeviceId");
|
|
update(null, null, "#ApiId");
|
|
$('#ajax').html('');
|
|
|
|
});
|
|
$('#DeviceId').change(function () {
|
|
var id = $(this).find(':selected').val();
|
|
update('@Url.Action("GetApiJson", "Ajax")', id, "#ApiId");
|
|
$('#ajax').html('');
|
|
});
|
|
$('#ApiId').change(function () {
|
|
var id = $(this).find(':selected').val();
|
|
$('#Url').parent().find('#ajax').html('');
|
|
var url = '@Url.Action("Api")?id=' + encodeURI(id);
|
|
$.get(url, function (html) {
|
|
$('#ajax').html(html);
|
|
reset();
|
|
});
|
|
|
|
});
|
|
});
|
|
</script> |