Reputation:
I have a working add-on. I am trying to fix a few small things. One thing I noticed was that some XUL files use a static string of the install.rdf's em:version
. One instance was typoed, and it generally annoys me to maintain one version string in multiple places. I want a solution such that I can change the em:version
, and use code to pick that string up in XUL files to insert into options.xul <dialogheader description="version">
tag. Another XUL file uses a <vbox> <text value="version">
, so I'd like to reuse the same code and technique there as well.
I've seen some examples of using JavaScript to access add-on version strings, but nothing explained how to reference that string from within an XUL element's attribute.
Upvotes: 0
Views: 117
Reputation: 33192
You cannot directly access the value from within your XUL file, but need to get the version with some Javascript and then set XUL attributes and/or text with the regular Javascript DOM APIs, so something along the lines of:
Cu.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("your-addon@id", function(addon) {
document.getElementById("version-header").setAttribute("value", addon.version);
});
Upvotes: 1