Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » Page Comment Interface - Disabling Javascript?

Discuss the Blog Module.

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

Page: 1 2
Go to End
Author Topic: 2264 Views
  • Garrett
    Avatar
    Community Member
    245 Posts

    Page Comment Interface - Disabling Javascript? Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

    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.

  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

    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

  • tzeller
    Avatar
    Community Member
    26 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

    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

  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

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

    Validator::set_javascript_validation_handler('none');

  • tzeller
    Avatar
    Community Member
    26 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

    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

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: Page Comment Interface - Disabling Javascript? Link to this post

    How disable prototype for template form?

    2264 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.