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?

4
  • And what exactly is your question? It is not clear exactly what you want help with or how one would get the right info to construct an appropriate path. Commented Nov 8, 2014 at 20:17
  • Sry, made an edit. better? Commented Nov 8, 2014 at 20:18
  • Is domain.com/application/themes/test known in advance or do you have to get that from somewhere? Commented Nov 8, 2014 at 20:18
  • That is known in advance. Commented Nov 8, 2014 at 20:19

2 Answers 2

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" />');
Sign up to request clarification or add additional context in comments.

Comments

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 } }
}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.