0

I am building a template for concrete5. The problem I am facing is that I have to access the css path from a javascript file. The plugin which has to do this uses:

breakpoints: {
        'global': { range: '*', href: '/css/style.css', containers: 0, grid: { gutters: 0 } }
    }

The file I am trying to access is located at

domain.com/application/themes/test/css/style.css

and not at

domain.com/css/stlye.css

Kinda stuck with my beginner javascript skills at this point. The console gives me the error 404 for the file. Makes sense since the style.css file is not located where I am searching it..

The js file is located at:

domain.com/application/themes/test/js/init.js

How can I access the style.css file?

Paco
  • 129
  • 1
  • 8

2 Answers2

1

If domain.com/application/themes/test is known in advance, then it appears that you can just do this in Javascript:

var path = "http://domain.com/application/themes/test" + breakpoints.global.href;

If you need to load that style file once you have the path, then you this answer shows you how to do that (you construct a <link> tag with that path in it and add that to the <head> section.

var path = "http://domain.com/application/themes/test" + breakpoints.global.href;
$('head').append('<link rel="stylesheet" href="' + path + '" type="text/css" />');
Community
  • 1
  • 1
jfriend00
  • 683,504
  • 96
  • 985
  • 979
0

I believe using the path below should work.

  /application/themes/test/css/style.css

placing the / in front of the url will make the browser look in the main folder first. That is why you were getting "domain.com/css/stlye.css" when you placed the url "/css/style.css" in your object.

So I would try the following changes to your object to see if it works:

 breakpoints: {
    'global': { range: '*', href: '/application/themes/test/css/style.css', containers: 0, grid: { gutters: 0 } }
}
Larry Lane
  • 2,141
  • 1
  • 12
  • 18