0
Welcome Guest! Login
0 items Join Now

SOLVED jQuery question

    • Pixelshift's Avatar
    • Pixelshift
    • Hero Rocketeer
    • Posts: 333
    • Thanks: 1
    • Audio Engineer | Web Design

    SOLVED jQuery question

    Posted 9 years 3 days ago
    • Can jQuery snips go into the JS particle? And do i have to turn on jQuery framework tabs?
    • Last Edit: 8 years 11 months ago by Pixelshift.
    • "5 out of 4 people have a problem with fractions..."
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 22303
    • Thanks: 3229
    • messin' with stuff

    Re: SOLVED jQuery question

    Posted 9 years 2 days ago
    • JS Atom you mean? I prefer to use the Assets area... but "yes" and "yes" is the answer I think... there's a good change jQuery is already loading, but if it's not, then enable the libary
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:
    • Pixelshift's Avatar
    • Pixelshift
    • Hero Rocketeer
    • Posts: 333
    • Thanks: 1
    • Audio Engineer | Web Design

    Re: SOLVED jQuery question

    Posted 9 years 1 day ago
    • Gotcha, maybe its my code then. Iv tried both the Atoms under Page Settings and the bottom section under Particle Defaults. But neither worked so i thought i wasnt doing something right, but maybe its just my code isnt right.

      Its probably not supported but im trying to do a fixed nav after scroll and here is the code i used to no avail, was the simpliest i could find as i dont have much experience with jQuery.

      $(window).bind('scroll', function () {
      if ($(window).scrollTop() > 50) {
      $('#g-navigation').addClass('fixed');
      } else {
      $('#g-navigation').removeClass('fixed');
      }
      });

      also tried...

      /* Dynamic top menu positioning
      *
      */

      var num = 50; //number of pixels before modifying styles

      $(window).bind('scroll', function () {
      if ($(window).scrollTop() > num) {
      $('#g-navigation').addClass('fixed');
      } else {
      $('#g-navigation').removeClass('fixed');
      }
      });

      with this in my css...

      .fixed {
      position:fixed;
      top:0;
      }

      Iv also noticed that if i make gantry load a file instead of using the inline feature, i'll see the script being called in the page source, but it adds strange numbers after the .js? Is this normal?

      Thanks again for the replys Matt
    • Last Edit: 9 years 1 day ago by Pixelshift.
    • "5 out of 4 people have a problem with fractions..."
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 22303
    • Thanks: 3229
    • messin' with stuff

    Re: SOLVED jQuery question

    Posted 9 years 1 day ago
    • yeah, the numbers just help Gantry keep track of what it's loading/being loaded

      Do you have any errors in Console related to your script? From your browser > Tools > More Tools > Developer Tools > Console

      I'm not a JS dev by any stretch of the imagination... a hack at best... but you may need to wrap that in a function, like:
      (function($) {
      
      $(window).bind('scroll', function () {
      if ($(window).scrollTop() > 50) {
      $('#g-navigation').addClass('fixed');
      } else {
      $('#g-navigation').removeClass('fixed');
      }
      });
      
      })(jQuery);

      Wherever you got that code... what jQuery library do they recommend? Is at least some version of jQuery being loaded on your page, in your <head>?
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:
    • Pixelshift's Avatar
    • Pixelshift
    • Hero Rocketeer
    • Posts: 333
    • Thanks: 1
    • Audio Engineer | Web Design

    Re: SOLVED jQuery question

    Posted 9 years 1 day ago
    • It seems i do have a few errors, but they all look related to some other widget in jomsocial, not sure if that has anything to do with the code not working.

      I can see the following scripts loading on my site...

      <script src="/media/jui/js/jquery.min.js"></script>
      <script src="/media/jui/js/jquery-noconflict.js"></script>
      <script src="/media/jui/js/jquery-migrate.min.js"></script>
      <script src="/media/jui/js/bootstrap.min.js"></script>
      <script src="/media/jui/js/jquery.ui.core.min.js"></script>
      <script src="/media/jui/js/jquery.ui.sortable.min.js"></script>

      and i can also see the code/your code loading on my site...

      (function($) {

      $(window).bind('scroll', function () {
      if ($(window).scrollTop() > 50) {
      $('#g-navigation').addClass('fixed');
      } else {
      $('#g-navigation').removeClass('fixed');
      }
      });

      })(jQuery);

      And as far as the original code goes, its just something i found via google search and landed here...

      stackoverflow.com/questions/13274592/lea...on-top-when-scrolled

      Also, here is a live working version of what im trying to do with the code shown...

      jsfiddle.net/adamb/F4BmP/

      iv tried about every version they have posted and then some lol

      Thanks for trying to help Matt =)
    • Last Edit: 9 years 1 day ago by Pixelshift.
    • "5 out of 4 people have a problem with fractions..."
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 22303
    • Thanks: 3229
    • messin' with stuff

    Re: SOLVED jQuery question

    Posted 9 years 1 day ago
    • post a link to your page
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:
    • Pixelshift's Avatar
    • Pixelshift
    • Hero Rocketeer
    • Posts: 333
    • Thanks: 1
    • Audio Engineer | Web Design

    Re: SOLVED jQuery question

    Posted 9 years 1 day ago
    • www.sessionrunner.com its still in beta mode so please excuse the mess lol
    • "5 out of 4 people have a problem with fractions..."
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 22303
    • Thanks: 3229
    • messin' with stuff

    Re: SOLVED jQuery question

    Posted 9 years 21 hours ago
    • hrm... in your Layout Manager go to your Section Settings for the Navigation section and add the class "test"

      ... I think you have to have an existing class="something" there in order to add/remove classes

      otherwise... what exactly are you expecting? that the nav bar stays normal for a bit and then gets that "fixed" class added to it after a certain scroll amount?
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:
    • Pixelshift's Avatar
    • Pixelshift
    • Hero Rocketeer
    • Posts: 333
    • Thanks: 1
    • Audio Engineer | Web Design

    Re: SOLVED jQuery question

    Posted 9 years 15 hours ago
    • Ok, added "test" in the CSS class field for the entire navigation location.

      And yes, basicaly im tring to have the nav bar go to a fixed top position after it scrolls to the top. Iv tried every code variation i could find but still no luck. Maybe its somethign with gantry im missing?

      Thanks again for the help Matt.
    • "5 out of 4 people have a problem with fractions..."
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 22303
    • Thanks: 3229
    • messin' with stuff

    Re: SOLVED jQuery question

    Posted 8 years 11 months ago
    • It's totally working now... the fixed class gets added now after you scroll down a bit... your CSS must need some love
    • Last Edit: 8 years 11 months ago by Matt.
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:

Time to create page: 0.067 seconds