Commit c61aedc1 by Valera Rozuvan Committed by Alexander Kryklia

Fix. Now can add more than one Poll to a vertical.

parent 58365ec9
...@@ -152,14 +152,14 @@ function PollMain(el) { ...@@ -152,14 +152,14 @@ function PollMain(el) {
this.questionEl = $(el).find('.poll_question'); this.questionEl = $(el).find('.poll_question');
if (this.questionEl.length !== 1) { if (this.questionEl.length !== 1) {
// We require one question DOM element. // We require one question DOM element.
logme('ERROR: PollMain constructor '); logme('ERROR: PollMain constructor requires one question DOM element.');
return; return;
} }
// Just a safety precussion. If we run this code more than once, multiple 'click' callback handlers will be // Just a safety precussion. If we run this code more than once, multiple 'click' callback handlers will be
// attached to the same DOM elements. We don't want this to happen. // attached to the same DOM elements. We don't want this to happen.
if (this.vertModEl.attr('poll_main_processed') === 'true') { if (this.questionEl.attr('poll_main_processed') === 'true') {
logme( logme(
'ERROR: PolMain JS constructor was called on a DOM element that has already been processed once.' 'ERROR: PolMain JS constructor was called on a DOM element that has already been processed once.'
); );
...@@ -169,7 +169,7 @@ function PollMain(el) { ...@@ -169,7 +169,7 @@ function PollMain(el) {
// This element was not processed earlier. // This element was not processed earlier.
// Make sure that next time we will not process this element a second time. // Make sure that next time we will not process this element a second time.
this.vertModEl.attr('poll_main_processed', 'true'); this.questionEl.attr('poll_main_processed', 'true');
// Access this object inside inner functions. // Access this object inside inner functions.
_this = this; _this = this;
...@@ -241,6 +241,18 @@ function PollMain(el) { ...@@ -241,6 +241,18 @@ function PollMain(el) {
} }
} }
if (
(this.jsonConfig.poll_answer.length > 0) &&
(this.jsonConfig.answers.hasOwnProperty(this.jsonConfig.poll_answer) === false)
) {
this.questionEl.append(
'<h3>Error!</h3>' +
'<p>XML data format changed. List of answers was modified, but poll data was not updated.</p>'
);
return;
}
// Get the DOM id of the question. // Get the DOM id of the question.
this.id = this.questionEl.attr('id'); this.id = this.questionEl.attr('id');
......
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