-
Notifications
You must be signed in to change notification settings - Fork 23
issue #825: Множество открытых окошек жалоб #826
Conversation
@mbaev, @awd-studio, посмотрите код.
Предлагайте, как можно оптимизировать (сократить) код |
'data-trigger' => 'click', | ||
'title' => $category, | ||
'data-trigger' => 'manual', | ||
'title' => $category . '<button type="button" class="btn-ticket-popover-close close">×</button>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very-very bad practice!
Добавь свой html-тэг ниже. Это будет генерировать не валидный html. Читай theme_html_tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне нужно вставить кнопку именно в title. Иначе она появляется где угодно, но только не в нужном месте. Как это сделать правильно?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Воспользовался JS для этого
var target = $(e.target); | ||
if (target.data('toggle') !== 'popover' | ||
&& target.parents('[data-toggle="ticket-popover"]').length === 0 | ||
&& target.parents('.popover.in').length === 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Читай closest jquery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поясни за closest и parents. closest лучше использовать, потому что он вернет только один подходящий элемент? Или почему ты рекомендуешь его использовать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, верно. Ищет первый подходящий и возвращает. Работает побыстрей.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В целом, норм. Так, ремарки по мелочам.
$('.popover-title').append('<button type="button" class="close btn-ticket-popover-close">×</button>'); | ||
}); | ||
// Close ticket-popover on click outside OR on click close button | ||
$('body').on('click', function(e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно оставить так, но обычно здесь используют $(document)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Изменю, чтобы в голове отложилось тоже)
}); | ||
// Close ticket-popover on click outside OR on click close button | ||
$('body').on('click', function(e) { | ||
var target = $(e.target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Про $target
помнишь? Не обязательно, но считается хорошей практикой.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, запоминаю потихоньку :)
"всего" в 3 коммита уложился, расту) |
Надеюсь ты потестил работоспособность в разных браузерах. |
Firefox и Chrome. |
А IE? |
На виртуалке, где я разрабатываю нет возможности поставить IE. И самое время спросить, а какую минимальную версию IE мы должны поддерживать? |
Можем поддерживать IE11 и EDGE |
#825