I am trying to create some global variables in a firefox extension. In my content folder, I have two javascript files:
1) Main JS file that holds the functions for the different events, etc
2) A file that stores only an object with the pieces of state I want to maintain. Also, I set the array EXPORTED_SYMBOLS.
I am having issues with the following line found in my main JS file:
Components.utils.import("resource:///globalVariables.js");
When it is at the top of the file, nothing seems to work. If I move it into the function where I need the variable, the rest of my code works, but the function with this line does nothing. Any advice that would help me with this problem would be great. Thanks
Chances are resource:///globalVariables.js is not the right URI. Make sure you register it properly, and include the aliasname when you reference it.
Related
I'm working on a new Acumatica screen for our company that will require some javascript code to retrieve and display a map object (from ESRI).
This code requires an external .js file that is included to the HTML by the javascript code itself. Everything works fine if I use a blank HTML page to test this.
The problem I have is that when I try using the same code from inside the Acumatica screen, it doesn't load this required external file, and therefore the code does not work properly.
I attempted to load the full .js file code along with my code, but it returned the following error:
error CS8095: Length of String constant exceeds current memory limit. Try splitting the string into multiple constants.
I haven't tried splitting this file into multiple strings (as the error message suggests), because I want to make sure there isn't a cleaner and more professional, direct/right way to do this.
Is it possible to manually import this external .js file into our Acumatica instance, so I can point to it instead? (in case it makes a difference if it's hosted in the same environment)
or, is there any way to make Acumatica able to load external files so we can keep using our current approach? (any setting that may be preventing external files from loading?)
I'm not sure i fully understand the question. What comes to mind however is you may be looking to use the PXJavaScript control. I used this link to help get my head wrapped around how to use the control. We had a need to trigger something off with Java Script and the PXJavaScript control got us to the end result we needed. Let me know if this gets you in the right direction?
Dynamically Change Button Color
I have been trying to figure out why my code is unable to be viewed in bl.ocks.org. I'd really like to see it up somewhere.
My code is for a bar chart that can handle changes in records and values created from a .csv file.
I have made sure that my code is working outside of this loading it from a local server from it's folder that contains the .html file and the .csv file.
I've ensured that it's not the browser cache either.
It can be found here: http://bl.ocks.org/parnelandr/7887491
Any help would be appreciated. I'm sure I've just missed something along the way.
The d3.js script you're referencing in your gist has a local path, i.e. it would need to be part of the gist as well, which it isn't. It should work fine if you either add d3.js or (preferably) reference the global URL to it instead.
I have a log.js file(it contains log function along with some properties) for debugging purpose.
I have two other js file which are the controlling various behavior of the web application.
Now I need to include the log function considering not to repeat the debug function in both the js file and just calling the file name.
How do I do it?
The idea is to make my code clean and separate them in other files to limit the size of a single js file.
Include all .js-files in the html page. Include log.js first.
Call the functions all you want.
All functions in all files are included in the source and are "written on the page", any functions can be accessed from anywhere within the HTML as they all become essentially one document. Make sure you do not have duplicate functions as this could cause an issue
I'm finishing my project right now and see that I've got a lot of javascript code on each page. It's not included as a ".js" file, but rather coded in the page itself. I figured it's a bad idea, so now I'm trying to put them all in one .js file and include it in each page.
The only problem I'm facing now is this: Some functions are only called on certain pages and are depending on the inclusion of jquery plugins. Not all pages needs the plugin however.
Example:
On the home page I need to chain the Country dropbox with the City dropbox, thus I need the jchained.js plugin for jquery. The code I need to use is:
$(function(){
$("#city").chained("#country");
});
When I add this function to the .js file, and I open a page where I don't need to chain the dropboxes I get logically an error:
TypeError: $("#city").chained is not a function
So if I understand this correctly, in order to use a .js file with all my different functions for different plugins, I need to include all the plugins to all the pages?
Thanks for your ideas & help.
Personally, I don't think you should worry about including alot of .js files, that's part of web development. Another option, albeit slightly more tedious, is you can make a check for the function to exist (if the plugin .js has been included) and then call it if it does:
if(typeof yourFunctionName == 'function') {
yourFunctionName();
}
It completely depends on how the code is structured or how complex the current code is.
An immediate solution will be,
Give an id to each page (may be on body tag).
Put all the code in a single external JavaScript file.
Execute the code meant for that particular page only if it has required id on that body element.
Something like :
if ( $('body').attr('id') == "home" ) {
/* Add home page JS here */
}
You can try this.
Correct me if I am wrong.
I'm currently stumped about a problem I'm facing where I can't reference functions and variables from one JavaScript file to the next. I've tried adding all of the JavaScript files as a library in File->Settings->JavaScript->Libraries but with no success - I still get the gray underline for references with, for instance, a hover-over message that reads "Unresolved function or method ".
The strange thing is if I move a copy of the JavaScript files outside of the subversioned project directory and then add that project-external reference to File->Settings->JavaScript->Libraries then the references are found but this solution is not satisfactory because these JavaScript files are updated via subversioning daily (we're in development)
Does anybody have any insight to my problem? If I am not going about this the right way then let me know. What I ultimately want to be able to do is reference variables and functions from specfic JavaScript files across all my JavaScript files so that I can easily follow references (ctrl+leftclick) to insure the parts are fitting together properly.
Thanks!
(P.S. I'm using PyCharm 2.5)