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) { function StudioContainerXBlockWithNestedXBlocksMixin(runtime, element) {
var $buttons = $(".add-xblock-component-button", element), var $buttons = $(".add-xblock-component-button", element),
$addComponent = $('.add-xblock-component', element),
$element = $(element); $element = $(element);
function isSingleInstance($button) { function isSingleInstance($button) {
return $button.data('single-instance'); return $button.data('single-instance');
} }
$buttons.click(function(ev) { // We use delegated events here, i.e., not binding a click event listener
var $this = $(this); // directly to $buttons, because we want to make sure any other click event
if ($this.is('.disabled')) { // 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.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
} else { } else {
if (isSingleInstance($this)) { if (isSingleInstance($button)) {
$this.addClass('disabled'); $button.addClass('disabled');
$this.attr('disabled', '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