Commit 7e7e6fc2 by Tim Krones Committed by GitHub

Merge pull request #39 from eliangcs/master

Fix bug: Single-instance buttons do nothing after disabled
parents 3dd2fce4 353f0123
function StudioContainerXBlockWithNestedXBlocksMixin(runtime, element) {
var $buttons = $(".add-xblock-component-button", element),
$addComponent = $('.add-xblock-component', element),
$element = $(element);
function isSingleInstance($button) {
return $button.data('single-instance');
}
$buttons.click(function(ev) {
var $this = $(this);
if ($this.is('.disabled')) {
// We use delegated events here, i.e., not binding a click event listener
// directly to $buttons, because we want to make sure any other click event
// listeners of the button are called first before we disable the button.
// Ref: OSPR-1393
$addComponent.on('click', '.add-xblock-component-button', function(ev) {
var $button = $(ev.currentTarget);
if ($button.is('.disabled')) {
ev.preventDefault();
ev.stopPropagation();
} else {
if (isSingleInstance($this)) {
$this.addClass('disabled');
$this.attr('disabled', 'disabled');
if (isSingleInstance($button)) {
$button.addClass('disabled');
$button.attr('disabled', 'disabled');
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment