File location is not found in js file - javascript

I develop one js file and also call one js file from it, but I cannot find file. Error is "file not found". I debug in firebug. File url is not generate well. Code is:
require(['modules/PageDecorator'], function(PageDecorator){
//initializing visual ui
PageDecorator.init();
});
it it, modules is folder and PageDecorator is js file.
url is generated
localhost/js/models/PageDecorator.js
however I need it to be:
localhost/test/js/models/PageDecorator.js
test is my root folder.

Related

angular project .js file generation configuration option

Please see this image. I see a constants.js file and "js.map" file under the constants.ts file. while I see no js file for other ts files. I understand that the type script compiler will generate the js file for each ts file. I am not sure why I can not see all the js files. I am not sure which configuration setting is affecting this. project is under source control. I only want to commit to the .ts files. I need to stop any ".js" or "js.map" files from being generated. not sure why it is only happening for one file. This is .Net core project with angular frontend.

Webpack Including JavaScript File via <script> Tag

I'm using Webpack with Storybook and need to include a JavaScript library file in an HTML file via a script tag. Unfortunately, I get a 404 error indicating that the file was not found (the file's path is based on my local filesystem and is correct). How do I inform Webpack regarding where to look for my library or "static" files?
Add files in entry object in webpack.config.js
entryPoint = {
app: ['path/to/script', 'path/to/script2','./index.js'],
};
This will make sure that you have the library loaded when you have run index.js (entry point of project).
More on Webpack entry points.

External JavaScript files not working in Rails

I have created a new Rails 4 project and I am trying to load an external JavaScript file in my HTML file. I have placed the JavaScript file in the /assets/javascripts directory and included the file in my HTML file.
My HTML file:
<html>
<body>
<script src="/assets/hello.js"></script>
</body>
</html>
My JavaScript file:
document.write("test");
I do not see any errors in my web browser console when loading the website. I am pretty sure I put the JavaScript file in to correct directory but the file will not run. Does Rails require something for external JavaScript files to work properly?
I have also tried defining a method in the JavaScript file and calling it within a <script> tag but I get a "Uncaught ReferenceError: methodname is not defined".
You probably need to list 'assets/hello.js' in application.js. The Rails asset pipeline compiles all JavaScript into application.js based on the filepaths that it finds listed there.
More info here: http://railsapps.github.io/rails-javascript-include-external.html
So I figured out why Rails wasn't loading my JavaScript file. When I created the Rails project, it included .coffee scripts which can be used instead of JavaScript. For some reason by default, the .coffee script was being run instead of the JavaScript file that I created. After deleting the .coffee script, my JavaScript loads as expected.

How to call saved javascript file from groovy

I have javascript (.js) file and if I was to call one of the function in that file how should I do that.
I followed following steps
Save the file under the directory src/test/groovy/Custom
Add the directory to class path
Call the function from another groovy file in following way
Code
import Custom
getElementsByClassName("info-links")
But Custom triggers Cannot resolve error
Using intelliJ 13.0.3 as my IDE
What went wrong?
Thanks

How to get the javascript file (JS) path which is stored in application bundle to html file which is there in document directory

I have one .js file named final.js which I copied as bundle resource I have a requirement like the html document which reads this js file should download at runtime and store it in documents directory. But the js file is not able to read by the html when I loaded it in webview, because of the path of .js file.
I tried with the solution like below, but not worked.
<script src ="./final.js"> </script>
And finally I tried to copy the hardcoded path of application bundle like below, now it worked. Finally I come to know that the path is not proper.
> <script src ="/Users/unknownUser/Library/Application Support/iPhone
> Simulator/7.0/Applications/025EF3B6-F2E6-4162-8921-839D7D98FF58/HTMLGetdataTestApp.app/final.js">
> </script>`
Can any one tell me that how a html file which is stored in documents directory can read a .js file which is stored in main bundle with the correct path instead of hardcoded like above.
The simple solution will be copying the final.js file to documents directory.
Copy the js file from bundle to the document directory (where the html page is located) and set the path as:
<script src ="final.js"> </script>

Categories

Resources