Skip to content

Commit

Permalink
Fix template function getting reused between blocks.
Browse files Browse the repository at this point in the history
The template function (which is slightly different for each block,
depending on block's configuration) was getting assigned to the global
DragAndDropBlock function. Each block would overwrite the previous
value, which caused bugs.
  • Loading branch information
mtyaka committed Jul 23, 2016
1 parent 7a1b1a0 commit ff7ddfd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drag_and_drop_v2/public/js/drag_and_drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ function DragAndDropTemplates(configuration) {
);
};

DragAndDropBlock.renderView = mainTemplate;

return mainTemplate;
}

function DragAndDropBlock(runtime, element, configuration) {
Expand All @@ -302,7 +301,8 @@ function DragAndDropBlock(runtime, element, configuration) {
DragAndDropBlock.STANDARD_MODE = 'standard';
DragAndDropBlock.ASSESSMENT_MODE = 'assessment';

DragAndDropTemplates(configuration);
var renderView = DragAndDropTemplates(configuration);

// Set up a mock for gettext if it isn't available in the client runtime:
if (!window.gettext) { window.gettext = function gettext_stub(string) { return string; }; }

Expand Down Expand Up @@ -882,7 +882,7 @@ function DragAndDropBlock(runtime, element, configuration) {
display_reset_button: Object.keys(state.items).length > 0,
};

return DragAndDropBlock.renderView(context);
return renderView(context);
};

/**
Expand Down

0 comments on commit ff7ddfd

Please sign in to comment.