21293 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1257 Views |
-
Page Comments - Javascript error

21 October 2010 at 10:01pm
Having enabled Page Comments on a page I have noticed a JS error.
It occurs when you click anywhere on the page after having entered some text in the 'Comments' textarea.
In IE the script halts the page from submitting (very bad). In FireFox the page submits, but the error is still there, and in Firebug I can get some details about it.
The error says, "$("PageCommentInterface_Form_PostCommentForm").validate is not a function".
I have been able to track this in the SS code as far as line 216 of /sapphire/forms/Validator.php where we see this block of code:
'#$formID textarea' : {
initialise: function() {
if(!this.old_onblur) this.old_onblur = function() { return true; }
if(!this.old_onfocus) this.old_onfocus = function() { return true; }
},
onblur : function() {
if(this.old_onblur()) {
return $('$formID').validate(this);
}
}
},...and it's the onblur call that causes the error.
Can someone advise what I can do here? (I'm running SS 2.4.0)
jf/
-
Re: Page Comments - Javascript error

23 October 2010 at 12:14am
Have you got any other javascript on this page? I ran into this issue and it was jquery_improvements calling noConflict() before jquery had loaded.
-
Re: Page Comments - Javascript error

23 October 2010 at 12:30am
Hi Willr
Yes, there's plenty of other JS going on, but it's (mostly) from the standard implementation.
I've attached the rendered source of the html page in question. Do you think you could take a look and see if you can spot where the conflict might be?
jf/
-
Re: Page Comments - Javascript error

23 October 2010 at 10:40am
Can't really debug from that but another way you can try to fix it is to block javascript files one at a time till you no longer get the error then work out why that files causing the trouble.
-
Re: Page Comments - Javascript error

25 October 2010 at 10:51pm Last edited: 25 October 2010 10:54pm
Hi Willr
Okay, I think it's something to do with these core files:
/cms/code/sitefeatures/PageCommentInterface.php
/sapphire/forms/Validator.phpHere's how far I've traced it:
In my rendered source code I eliminated one-by-one the JS files until the error stopped. That led me to this file:
/thirdparty/behaviour/behaviour.jsThat file is included by:
/cms/code/sitefeatures/PageCommentInterface.php
So I commented it out.Something odd then happened. When I re-examined the source code being rendered I noticed that /thirdparty/behaviour/behaviour.js was still being included - but in a different place(!). I tracked it down to this file:
/sapphire/forms/Validator.phpSo I'm not quite sure how that happens, but SS appears to be saying something like, "if behaviour.js is not already included by PageCommentInterface.php, then Validator.php will include it." I checked other permutations and I'll summarise below:
Comment out from neither - file is included by PageCommentInterface.php
Comment out from PageCommentInterface.php only - file is included by Validator.php
Comment out from Validator.php only - file is included by PageCommentInterface.php
Comment out from both - file is not includedSo, that's the first conumdrum.
The second is that, as soon as I manage to stop the file from being included, I instantly hit a new error on page load:
"Behaviour is not defined"
which I imagine will be no surprise.So, where now? Am I even looking in the right place?
jf/
-
Re: Page Comments - Javascript error

3 November 2010 at 11:30pm
Do I need to report this as a bug?
jf/
| 1257 Views | ||
|
Page:
1
|
Go to Top |


