fix selector problem with click #53
This commit is contained in:
parent
8a298ec443
commit
c48ab36903
|
|
@ -24,6 +24,9 @@ function changeSwitch(checkboxElem, idx) {
|
|||
|
||||
// switchSelector
|
||||
function switchSelector(idx, lvl, bid) {
|
||||
|
||||
var old_bid = bid.replace(new RegExp(lvl + '$'), '');
|
||||
//var old_index = bid.replace(lvl, '');
|
||||
url = '/api?type=devices&rid=' + idx;
|
||||
requestAPI(flask_server + url, function(d) {
|
||||
r = JSON.parse(d);
|
||||
|
|
@ -31,8 +34,8 @@ function switchSelector(idx, lvl, bid) {
|
|||
if (last_active != 0) {
|
||||
last_active = last_active + 0;
|
||||
}
|
||||
$('#' + bid + last_active).removeClass('btn-primary');
|
||||
$('#' + bid + lvl).addClass('btn-primary');
|
||||
$('#' + old_bid + last_active).removeClass('btn-primary');
|
||||
$('#' + bid).addClass('btn-primary');
|
||||
requestAPI(flask_server + '/api?type=command¶m=switchlight&idx=' + idx + '&switchcmd=Set%20Level&level=' + lvl + '&passcode=');
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,11 +152,10 @@ $(document).ready(function() {
|
|||
btnClass = 'btn btn-responsive';
|
||||
}
|
||||
bid = 'selector_{{v[1]}}_block_{{count}}_index_';
|
||||
b = '<button id="' + bid + i + '" class="' + btnClass + '">' + lvlname + '</button>';
|
||||
b = '<button id="' + bid + i + '" onclick="switchSelector({{v[1]}}, ' + i + ', this.id)" class="' + btnClass + '">' + lvlname + '</button>';
|
||||
$('#selector_body_{{v[1]}}_block_{{count}}').append(b);
|
||||
$('#' + bid + i).click(function(e) {
|
||||
$('#' + 'selector_{{v[1]}}_block_{{count}}_index_' + i).click(function(e) {
|
||||
e.preventDefault();
|
||||
switchSelector({{v[1]}}, i, bid);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -183,5 +182,4 @@ $(document).ready(function() {
|
|||
setInterval(refreshSetpoints, 9000, updateSetpoints_block_{{count}}, {{count}});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue