Если вы указываете сценарий для создания контейнера со статическим именем - например, в вашем случае - он не будет воссоздан, так как модуль AzureRM обнаруживает, что указанная группа контейнеров уже существует. Попробуйте добавить «Remove-AzureRmContainerGroup ...» в одну строку над «New-AzureRmContainerGroup ...»
Рассмотрим объявление глобальной переменной.
// Start notification countdown
$.countDownNotification = function(notification) {
// IMPORTANT: Store the setInterval in a element-specific variable?
timer = setInterval( function() {
// Counts down from 10 and stores new value in data-attribute
notification.attr('data-timer', notification.attr('data-timer') - 1);
}, 1000);
// Remove notification when timer is on 0
if ( newRemaining == 0 ) {
notification.remove();
}
}
// `false` means no timer has been set
var timer = false;
// Pause on hover
$('.notification').on('mouseenter', function(e) {
// IMPORTANT: Clear the elemnt-specific interval
clearInterval( timer );
});
// Resume when hover ends
$('.notification').on('mouseleave', function(e) {
var notification = $(this)
$.countDownNotification(notification);
});
Другой способ не устанавливать глобальный объект - это вернуть setInterval()
на .countDownNotification
.
// Start notification countdown
$.countDownNotification = function(notification) {
// IMPORTANT: Store the setInterval in a element-specific variable?
var id = setInterval( function() {
// Counts down from 10 and stores new value in data-attribute
notification.attr('data-timer', notification.attr('data-timer') - 1);
}, 1000);
// Remove notification when timer is on 0
if ( newRemaining == 0 ) {
notification.remove();
}
return id;
}
( function() {
// `false` means no timer has been set
var timer = false;
// Pause on hover
$('.notification').on('mouseenter', function(e) {
// IMPORTANT: Clear the elemnt-specific interval
clearInterval( timer );
});
// Resume when hover ends
$('.notification').on('mouseleave', function(e) {
var notification = $(this)
timer = $.countDownNotification(notification);
});
})();
Вы можете сохранить интервал в уведомлении через .data()
.
notification.data('int', setInterval(...
Затем, в обратных вызовах событий вы можете ссылаться на интервал через
$(this).data('int')
Также, примечание + 1 - 1 не делает ничего значимого.