Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

Page Comment Interface - Disabling Javascript?


Go to End
Reply


9 Posts   2679 Views

Avatar
Garrett

Community Member, 245 Posts

11 March 2010 at 8:50am

Edited: 11/03/2010 8:51am

Hi,

I have a custom jQuery dropdown menu I use on my blog module. This works fine on the BlogHolder, but on the BlogEntry template, No matter WHAT I do, I CANNOT keep these SIX javascripts from attaching themselves:

prototype.js
behaviour.js
prototype_improvements.js
i18n.js
en_US.js
Validator.js

I have commented the Requirements lines in PageCommentInterface.php, in addition to setting use_ajax_commenting to false, in PageCommentInterface.php as well as in _config.php, but they STILL get attached to the page! I HAVE to remove these as the code conflicts with elements/functionality already in my template.

Does anyone know how to remove this, or is there a jQuery Page Comment Interface available?

I'm running SS 2.3.6.

Thanks,
Garrett

Avatar
Willr

Forum Moderator, 5516 Posts

11 March 2010 at 11:36am

Tried using Requirements::block()?

simon_w has rewritten page comments to use jquery - http://open.silverstripe.org/ticket/4814. Not been merged into core just yet.

Avatar
Garrett

Community Member, 245 Posts

11 March 2010 at 11:48am

Edited: 11/03/2010 11:49am

Hey @willr.

Yeah, I did try using that-- it works and removes the scripts,-- but it still writes a bunch of JS to the page even without these script attachments. Just loose in-page script at the bottom:

<script type="text/javascript">//<![CDATA[
Behaviour.register({
	'#PageCommentInterface_Form_PostCommentForm': {
		validate : function(fromAnOnBlur) {
			initialiseForm(this, fromAnOnBlur);
			
			
			var error = hasHadFormError();
			if(!error && fromAnOnBlur) clearErrorMessage(fromAnOnBlur);
			
			return !error;
		},
		onsubmit : function() {
			if(typeof this.bypassValidation == 'undefined' || !this.bypassValidation) return this.validate();
		}
	},
	'#PageCommentInterface_Form_PostCommentForm input' : {
		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()) {
				// Don't perform instant validation for CalendarDateField fields; it creates usability wierdness.
				if(this.parentNode.className.indexOf('calendardate') == -1 || this.value) {
					return $('PageCommentInterface_Form_PostCommentForm').validate(this);
				} else {
					return true;
				}
			}
		}
	},
	'#PageCommentInterface_Form_PostCommentForm select' : {
		initialise: function() {
			if(!this.old_onblur) this.old_onblur = function() { return true; } 
		},
		onblur : function() {
			if(this.old_onblur()) {
				return $('PageCommentInterface_Form_PostCommentForm').validate(this); 
			}
		}
	}
});

//]]>

Can't figure out where this is coming from.

//Garrett

Avatar
tzeller

Community Member, 26 Posts

9 July 2010 at 1:15am

Hey Garrett

i have got the same problem - it does this also with the $SearchForm. Have you figured out how to get this bunch of JS out. It stops allowing me a "slideDown" and "slideUp" event from jquery.

thanks

Tobias

Avatar
Garrett

Community Member, 245 Posts

9 July 2010 at 1:41am

No, I never figured it out. I ended up just re-enabling it and then adding some script around my jQuery code to make Prototype ignore it. Wrap all your jQuery calls in this:

;(function($) {

......
})(jQuery);

Hope that helps,
Garrett

Avatar
Willr

Forum Moderator, 5516 Posts

10 July 2010 at 11:53am

Edited: 10/07/2010 8:39pm

Also you can disable the prototype validation. I think that will remove that code

Validator::set_javascript_validation_handler('none');

Avatar
tzeller

Community Member, 26 Posts

10 July 2010 at 8:37pm

Great Willr thanks it works perfectly! all your contribution and help here in the forum is really outstanding.. i have used your answers very often already...

tobias

Avatar
biapar

Forum Moderator, 435 Posts

21 November 2010 at 4:14am

How disable prototype for template form?

Go to Top