Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Quick question about double alert messages

Quick question about double alert messages 5 years 1 month ago #64646

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Hi Team,

I don't think that this is the right place to ask this question so feel free to delete the question.

Can you point me in the right direction as to why the alert in the following question is repeating twice? The code initiates when a previous/next button is clicked, and the alert is correctly only shown when the 'Next' button is clicked. However, the alert repeats twice. Any ideas or pointing me into the right direction would be brilliant.
$(document).ready(function() {
	$('form#limesurvey').submit(function(){	
 
 
		if (document.limesurvey.move.value == 'moveprev') {
		}
 
		else {
			$('#moveprevbtn, #movenextbtn, #movesubmitbtn').attr('disabled', '');
			alert("FORWARD");
 
		};
 
	});
 
});
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64669

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6315
  • Thank you received: 1407
  • Karma: 546
What version are you using? There was a bug causing the submit function to fire twice but I believe it was fixed - bugs.limesurvey.org/view.php?id=4985
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64672

  • paulfiner
  • paulfiner's Avatar
  • Offline
  • Expert Lime
  • Posts: 92
  • Thank you received: 1
  • Karma: 1
I too am seeing double alert messages. I'm using the latest build.

Cheers

Paul
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64673

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
I couldn't find the build number but the bottom of the screen reads as v1.91+ which I think is later than Bugfix in the report.

Any ideas how to get around the problem?
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64674

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6315
  • Thank you received: 1407
  • Karma: 546
Can one of you please activate a sample survey?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64676

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Hi both :)

The bug isn't replicated using the sample survey in the bug report that you linked. Also, by constant breakpoints and commenting out, I've managed to locate what seems to be causing the problem but I have no idea why it would be causing such an issue.

In the same script, I am using the 'Multiple questions types' workaround from here: docs.limesurvey.org/tiki-index.php?page=...stion_types_in_array

The double messages only appear when the line is run:
    $('.'+this+'').wrapAll('<div id="inlineWrapper'+i+'" class="inlineRow" />');

The line in context is:
//Wrap each "row" in a wrapper div
$(rowList).each(function(i) {
    $('.'+this+'').wrapAll('<div id="inlineWrapper'+i+'" class="inlineRow" />');
}); 

I have commented out the line, and the script runs perfectly (though the layout from the workaround does not work).

I have also commented out later reference to inlineWrapper and inlineRow but these have no impact at all. Consequently, I think it is something to do with wrapAll (I've also checked and 'this' doesn't ever seem to call the submit button)

Any ideas?

J.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64679

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6315
  • Thank you received: 1407
  • Karma: 546
Not really. In that line, 'this' simply references an array item that is being inserted as a class for the selector. All elements that match the selector are then wrapped in a new <div> element. So the loop is actually:
$('qRow0 ').wrapAll('<div id="inlineWrapper0" class="inlineRow" />');
$('qRow1 ').wrapAll('<div id="inlineWrapper1" class="inlineRow" />');
$('qRow2 ').wrapAll('<div id="inlineWrapper2" class="inlineRow" />');
$('qRow3 ').wrapAll('<div id="inlineWrapper3" class="inlineRow" />');
...

And I still haven't been able to reproduce it. Is it browser-specific?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64680

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Yep, I put breakpoints in to see the value of 'this' before, and it produced something similar to the output you provided.

I have reproduced the error in Chrome, IE, Safari and Firefox (all latest versions).

I can't work out why commenting out that line solves the problem.

The error still occurs even when I choose different names for 'inlineWrapper/Row' (just in case it was an issue of the script halting because other lines relied on that line being present).

Hmm.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64682

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6315
  • Thank you received: 1407
  • Karma: 546
Can you activate a small sample survey?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64695

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Hi Tony,

Sure, if you don't mind having a look.

phd-research.limequery.com/38368/lang-en

Thanks, J.
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64698

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6315
  • Thank you received: 1407
  • Karma: 546
Okay, I don't get what is firing the submit function twice. Can you attach the survey here (or send me a PM if it's sensitive) so I can test it directly?

Paul, are you only seeing the problem when using the 'Multiple questions types' workaround?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.
The following user(s) said Thank You: doodsonj

Quick question about double alert messages 5 years 1 month ago #64700

  • paulfiner
  • paulfiner's Avatar
  • Offline
  • Expert Lime
  • Posts: 92
  • Thank you received: 1
  • Karma: 1
Hi Tony

Just doing a quick test, it looks like it is only happening on the Multiple questions workaround.
Putting up an alert on a normal question on the next page only gave one alert.

Cheers

Paul
The administrator has disabled public write access.

Quick question about double alert messages 5 years 1 month ago #64718

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2

File Attachment:

File Name: limesurvey...p_45.lsg
File Size:150 KB

Hi Tony,

Thanks for offering, though don't worry if you don't have time or more important/exciting things to do.

I have attached the script.

To make the script work, you'll likely to have change the variable qHiddenTextIDNum1 to the qID of GroupsGroupsHidden (a long-text field at the end of the list).

Sorry about the state of the code, I'm still writing the code and haven't had chance to make it all super clean and pretty yet.

Peter - feel free to use any part of the (rather ugly at the moment) script as the script combines the ability to multiples types of question in an array, add/remove rows, validation colouring (i.e. highlighting rows). This script is probably the simplest that I have but I've got a few others that I've written which have added a few other features (or used existing code from the workarounds).

File Attachment:

File Name: limesurvey...p_45.lsg
File Size:150 KB



J.
Last Edit: 5 years 1 month ago by doodsonj. Reason: Wrong file
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu

Quick question about double alert messages 5 years 1 month ago #64735

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6315
  • Thank you received: 1407
  • Karma: 546
Okay, got it!

jQuery is getting getting confused when wrapping an element that contains a script. It seems to leave a ghost image of the script so there are effectively two scripts and therefor two $('form#limesurvey').submit() calls.

I see 2 solutions, the first being the easiest to implement and the second making future development far easier (you don't have to mess with the editor):

1) Move the script to the source of the group description.

2) Move the script to template.js and wrap most of it in an IF statement so it only fires when on that page. Something like this:
var qHiddenTextIDNum1 = 1196;
 
if($('#question'+qHiddenTextIDNum1+'').length > 0) {
 
	var myGlobalRows = 10;
	var myGlobalColumns = 3;
	var RowCutOffFreetext = 6;		       
	var RowCutOffHide = 6;
	var RowCutOffHideOriginal = RowCutOffHide;
	var myArrayTableTracker = new Array(myGlobalRows); 
 
	//// And the code continues here....
 
}
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 1 month ago by tpartner.
The administrator has disabled public write access.
The following user(s) said Thank You: doodsonj

Quick question about double alert messages 5 years 1 month ago #64740

  • doodsonj
  • doodsonj's Avatar
  • Offline
  • Junior Lime
  • Posts: 30
  • Thank you received: 2
  • Karma: 2
Perfect. That has solved everything :) HURRAH, Tony.

I think it is about time that I donate some money to the cause, so I'll get onto that in the next 12 hours :)

As ever, thank you so much for helping me out with my problem.

Peter - if you're implementation is similar to mine, then this solves the problem.

J.
The administrator has disabled public write access.
Time to create page: 0.252 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form