2

I've been asked to take a look at a civicrm installation on wordpress. They are having trouble getting an event page to work correctly. I found that there are lots of javascript errors being thrown. When I look at the page source of the registration page I see lots of p and /p tags in with the javascript which is causing script errors. e.g.

<script type="text/javascript"></p>
<p>var thousandMarker = ',';
var separator      = '.';
var symbol         = '$';
var optionSep      = '|';</p>
<p>cj("#priceset [price]").each(function () {</p>
<p>    var elementType =  cj(this).attr('type');
   if ( this.tagName == 'SELECT' ) {
      elementType = 'select-one';
   }</p>
<p>    switch(elementType) {

The first line throws an error of SyntaxError: expected expression, got '<'

Any idea what could be causing this? I'm not very familiar with wordpress. I reviewed the plugins they have and don't see anything obvious. (They are running wordpress 4.7 and civicrm 4.7.13).

2
  • have you compared this with what you get on the WP civicrm demo site?
    – petednz - fuzion
    Commented Dec 14, 2016 at 3:31
  • No real reason to. Its obviously invalid scripting. I've temporarily changed their template and the problem went away. Its something with their template.
    – Jay Edgar
    Commented Dec 15, 2016 at 14:12

1 Answer 1

1

Sounds like some javascript got pasted into a rich text editor ("WYSIWYG"), and the result is linebreaks in the JS are being interpreted as content linebreaks and wrapped in <p> container.

Simple fix: edit the content containing the JS, and use the "View Source" button or equivalent to enter the JS in source mode rather than content mode.

More robust approach (less easy to break, etc): add the JS via a custom template (see "Appending jQuery or other code") or from a custom extension.

4
  • If this is not the cause, it's possible the site is using a theme or plugin which post-processes CiviCRM's output and is not doing so cleanly. Commented Dec 13, 2016 at 23:40
  • Thanks, These two causes were what I was thinking of as well. I currently don't have access to the file system of the server. I'm thinking of trying: 1. temporarily try a different template (I'm betting this fixes it) 2. ask those who do have access to either give me access or to let me know if there are any over ride files in civicrm's provisioned custom script directory.
    – Jay Edgar
    Commented Dec 14, 2016 at 14:50
  • My first proposal should be something you can check through web UI, by editing the Contribution page (or other entity with editable field) affected. Good luck! Commented Dec 14, 2016 at 21:46
  • Changing the template fixed it. Now I just need to recreate the original template or figure out what is wrong with it.
    – Jay Edgar
    Commented Dec 14, 2016 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.