Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Problem after update to 1.0.9

Started by Muut Archive 10 years ago · 4 replies · 337 views
10 years ago

After update to 1.0.9, I face an error in a Jquery script.

Error is given as:
Uncaught Error: Syntax error, unrecognized expression: a[href*=#]:not([href=#])

I am using theme Antimatter.
I introduced this script from Mediator Theme to makes a curtain effect (arriving on page, there is a picture covering screen and on click on a arrow, this script makes the curtain opens itself on post).
It was working prefectly until update 1.0.9.

Probably the update to JQuery 2.2.0 is related to this, but I don't know ??

I also update skeleton Mediator to check if it would have same problem but it did not make the same result: script in Mediator continued to work fine, while it's exactly same redaction!

I really don't know what to do!

Thank in advance for help.

Tidivoit

Here is the script: (problem is at line 21 $('a[href*=#]:not([href=#])').click(function() {


<script>
(function ($) {
"use strict";
$(document).ready(function(){

JS
var $window = $(window),
$image = $('.curtain-image-image');
$window.on('scroll', function() {
  var top = $window.scrollTop();

  if (top < 0 || top > 1500) { return; }
  $image
    .css('transform', 'translate3d(0px, '+top/3+'px, 0px)')
    .css('opacity', 1-Math.max(top/700, 0));
});
$window.trigger('scroll');

var height = $('.curtain-image').height();
$('.curtain-content').css('padding-top', height + 'px');

$('a[href*=#]:not([href=#])').click(function() {
  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
   && location.hostname == this.hostname) {
    var target = $(this.hash);
    target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
    if (target.length) {
      $('html,body').animate({ scrollTop: target.offset().top }, 500);
      return false;
    }
  }
});

});
}(jQuery));
</script>

10 years ago

Not sure about the problem specifically as i'm not jQuery expert, however you can revert to the older jQuery 2.1.4 which is still packed in Grav. Simply add this to your user/config/system.yaml:

YAML
assets:
  collections:
    jquery: system://assets/jquery/jquery-2.1.4.min.js
10 years ago

Thanks: I am checking that right now: thank you very much for answering.

10 years ago

Your suggestion made it: it's working again!!!
Thank you very much.

A question: is it possible to call jquery-2.1.4 just for that particular page? (How?)

Other point:
how is it possible that jquery upgrade affects my particular project and not upgraded Mediator theme? ! ? (as script are exactly the sames)

10 years ago

OK here is the answer:

ERROR is:
a[href*=#]:not([href=#])

SOLUTION is:
a[href*="#"]:not([href="#"])
selectors have to be identified as a string that is to say nested

HERE is 2 REFERENCES:
REFERENCE1
REFERENCE2

☆ Thanks goes to @rhuster for help ♪

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1356 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago