Hello,
so I implemented a gadget that shows information based on filters that users can configure. Currently I am having a static title defined in the ModulePrefs in gadget.xml title="__MSG_gadget.title__" which refers to the gadget.title in messages.xml. This all works fine and well, but how do I implement a dynamic title?
Or more precise: How can I set the title to the name of the current filter in use? A generic method of dynamically setting the title would be perfect for future use.
Regards
Chris
You need to identify the gadget:
var gadget = [
{
id:
title:
}]
and then add the function.
if(text)
text.title = item.title;
Hope this helps a bit.
Hi Albrit,
it looks like something of the right direction, although I seem to be missing where and what to put.
'identifiy the gadget':
Do you mean, find the gadget in a javascript context and then change its value? Im not sure where this happens. Also I am wondering about the code you posted. Either I'm stuck with my thoughts, or there is some information missing.
Or is this inside the gadget.xml where you put the javascript code? Can you give me some more information?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"How can I set the title to the name of the current filter in use?"
On gadget.xml you need to define your UserPref:
<UserPref name="name" display_name="Title:" datatype="string"/>
On myPlugin.js (which is your JavaScript file) you write the function:
var gadget = [
{
id:"gadget-key",
title: "" // Empty
}];
gadget.forEach(function(item) {
var element = parent.document.getElementById(item.id) // where element is the title
if (element) { // if there is an input for title
item.title = prefs.getString("name"); // here you can use some JavaScript API
}
});
And that should be all.
If this does the trick you are looking for, please accept my answer for future use.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.