So I have a file foo.js which contains the following:
$( document ).ready(function() {
alert("hello world");
});
and if I put it to the web/static/js folder then it doesn't get executed, but if I put it to the web/static/vendor folder then it does, so I wonder why it doesn't work from the js folder? And where should I put my js files? The vendor folder doesn't seem to be the right place ...
As phoenixframework is using bruch.io as default.
In it default configuration. There are two javascript folders
web/static/js
web/static/vendor
When you add .js files under /web/static/vendor these files will be put in non wrapped codebase. These files will undergo concatinations and other processes and brunch.io with other js files (which also include files under web/static/js) and then will be put it in priv/static/js/app.js
When you add .js files under web/static/js these files content will be put in wrapped codebase and then these file will undergo concatination with other brunch.io processes like previously mentioned. To reference to these file you need to use require() To require it first then you can use it.
I hope you understand the reasons here. I researched from https://github.com/brunch/brunch-guide/blob/master/content/en/chapter04-starting-from-scratch.md.
And these configuration can be overriden in the file brunch-config.js or brunch-config.coffee in the phoenixframework geterated folder content.
It turns out that when you add new files to the js folder, you have to require it either in your html file or in app.js, that's one of the brunch's features
Related
I am new to Aurelia and working on a project using aurelia-cli. I noticed that the generated sourcemap includes absolute path names for my html template files. I prefer that the sourcemap did not include absolute path names. Alternatively, and maybe preferably, I would like the html file names left out of the sourcemap altogether since html files are not very useful in the sourcemap. How can I get aurelia-cli to put relative file names in the sourcemap or to remove references to html files altogether?
This is a bug in the CLI. It has been fixed, but the fix has not been released. It should be released today.
Here is the commit that fixed the bug: https://github.com/aurelia/cli/commit/127a8abc15e23fcbe2ceee42582baafbea5acb74
I need some suggestions to transfer javascript code in html files to typescript files in Visual Studio 2015.
Right now, I have 4 HTML views, where I want to take out the javascript code and convert it to the typescript files. The views are:
Travel.cshtml,
Hotel.cshtml,
Tpa.cshtml,
Passengers.cshtml
Every view contains html code + razor and a javascript section.
I'm trying to create 4 typescript files and link them to the view. As the image shows, I have created the files in a folder called "pages". For now they are all just empty :)
How can I link those pages to the representative views, so that the
Travel.ts file is linked to the Travel.cshtml file?
Some may ask, why am I doing this? .. I'm doing this to get clean html files with no javascript in, so its easier to read. Also I need to learn the typescript syntax which is a little difficult for me.
Hope someone can help.
Valid javascript code is valid typescript code. So to get started, you can use your existing javascript code inside your typescript files.
Every time you save your typescript file in visual studio, typescript compiler will be compiling this file and generate the corresponding javascript file with the same name as of your typescript file name, provided you do not have any errors in your typescript file.The generated file will be in the same location of where you have your typescript files are. If you want to see those, you can enable the Show All files option in solution explorer.
You will not include the typescript files in your pages, instead we will use the generated js files. So in your case, in your Hotels view(Hotels.cshtml), you can include it like
#section Scripts
{
<script src="~/Content/Scripts/Pages/Hotels.js"></script>
}
Or if you want to bundle it, Add a new bundle in your RegisterBundles() method.
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/hotels").Include(
"~/Content/Scripts/Pages/Hotels.js"));
// Other bundles goes here
}
And in your view, use the bundle path
#section Scripts
{
#Scripts.Render("~/bundles/hotels")
}
I am using sass with prepros compiler and sublime editor. I need to have each scss file complied with the same file name.
For example:
I currently have-
header.scss
content-top.scss
footer.scss
and they are all compiles into style.css to create one full style sheet.
I wish to have a style folder with
header.css
content-top.css
footer.css
which will be done automatically when saving and compiling like I normally do.
How can I accomplish this?
Thank you
Check this link out.
It states that you can adjust your project structure (in your case CSS folders) in project settings.
If I remember correctly you may have to buy it so that you can compile more than 4 or 5 Sass files, but I may be wrong.
Also check that you aren't "only" importing sass partials because of this:
Any Sass and Scss file (i.e. including partials) imported by another
file are not shown in the files list but they are still watched by Prepros.
The parent file is re-compiled whenever any of the imported files are changed.
I don't know why my filewatcher doesn't transpile certain scss files. I wanted to rename files that already existed to use them as partials. That worked fine for most of them but i couldn't rename all of them. When I tried to use "refactor->rename" there was a warning that the files would be used by another script but that was definitly not the case. I was not able to rename them in phpStorm so i renamed them in the directory manually. That worked but now no css files are created anymore. I tried to synchronize but that didn't help. My settings seems to be correct (see picture). Anyone had the same problem before and knows the solution?
When "Track only root files" option is on, the content of partials is merged into a single .css files when transpiling, so that a single css is generated instead of creating a separate css for each partial
I have implemented jqgrid within asp.net 3.5 vs2010. It is working fine as long as the asp.net page is onthe root folder, but when I move the page to a subfolder it tries to look for the js and css files with the foder under subfolder. The js and css files are in a folder under the root folder.
I am using the folowing code to reference to jquery files:
What it does is it appends the subfolder name to the path and the application is not able to find the js and css files. e.g /Scripts/jquery.jqGrid.js
How do I reference the js and css files under the html tag of asp.net page?
If you use developer version of jaGrid you have to modify the variable pathtojsfiles from the jquery.jqGrid.js depend on the path where you place jqGrid on your site.
I recommend you to include all files listed in jquery.jqGrid.js instead of using jquery.jqGrid.js. See this and this answers for more information.