URL rewriting messing up jQuery

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
I'm trying to do things with jQuery on my pages and it works for any page that is not rewritten with the URL rewrite stuff... but anything that turns out like this:

http://www.domain.com/manufacturer/2-general-electric.aspx

the scripts don't seem to want to work.

Anyone have issues like this? Is there a fix? Where do I look?



Thanks
13 years ago
Sounds like you are registering the scripts on your page with a relative path.

Try registering from the code behind and use a virtual path i.e. ~/scripts/yourscript.js

If you look in the code behind for the product detail module you can see how the lightbox script is registered.

HTH
Ben
13 years ago
I assume that you're talking about this:

string slimBox = CommonHelper.GetStoreLocation() + "Scripts/slimbox2.js";
Page.ClientScript.RegisterClientScriptInclude(slimBox, slimBox);

in onPreRender.... ???

I registered my script the same way and it shows up with the full path in my page (you can see it when you view source on the page), but the script just doesn't work. You go to a page that doesn't have the URL rewritten and it works just fine.

I don't get it.
13 years ago
Come to think of it, there are several things that I am doing with the script and SOME of it does work in the URL rewrite pages...

var j$ = jQuery.noConflict();
    
j$(document).ready(function () {
      
  -- THIS DOES NOT WORK WITH URL REWRITE --

  j$('#whatsincart').load('cartresults.asp');
      
  j$.get('cartresults.asp', function(data){
    alert("Data Loaded: " + data);      
  });


-- THIS DOES WORK WITH URL REWRITE --
      
        var top = j$('#smc_cart').offset().top - 15 //parseFloat(j$('#smc_cart').css('margin-top').replace(/auto/, 0));

  j$(window).scroll(function (event){
  // what the y position of the scroll is
  var y = j$(this).scrollTop();
  // whether that's below the form
  if (y >= top) {
    // if so, ad the fixed class
    j$('#smc_cart').addClass('fixed');
  } else {
    // otherwise remove it
    j$('#smc_cart').removeClass('fixed');
  }
  });
});


With the first bits of code I'm trying to load something from another page into a <div>... update only that <div> on a click (eventually)... doesn't work.

With the second part I have the mini shopping cart follow you as you scroll down so you can always see what's in your cart... that works just fine.

How come one thing works and the other doesn't???

I don't have an idea what's wrong.


hm...
13 years ago
I was so worried about the path to the scripts that I didn't realilze that I needed absolute paths to the files that I was trying to access with the script.

Problem solved.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.