Sign in to follow this  
Followers 0
7twenty

issue help with checkbox/variable/newtab

2 posts in this topic

Probably not going to get a reply... but will give it a go and see what happens.

I'm having trouble getting the "activate" parameter of the newtab function to work when the string is called from a variable.

In:

 mxTabs.newTab({url:"url", activate:true, position:"afterCurrrent"});

when activate is set to true or false directly in that line it works fine. If I have a variable "openTab" set to true or false and called in that same line "activate:openTab" it also works.

But if I have a variable "openTab" with a value set to true or false which is determined from some javascript, and then saved and called via the mx.storage api, it never seems to work and always defaults to "true".

Doing an alert (openTab) or rt.storage.getConfig("openTab") shows that the string is correct.

Getting quite annoying, as I know what I want to do and i'm pretty sure i've got it all right, but this just won't work.

Share this post


Link to post
Share on other sites

In javascript environment, If your variable is not a boolean, every value of variable represents true except "0" string, undefined or null value. You must compare storage value to what you need.

var mxRuntime = window.external.mxGetRuntime(),
    mxStorage = mxRuntime.storage,
    mxTabs = mxRuntime.create('mx.browser.tabs');

var activate = mxStorage.getConfig('openTab') == 'true';
mxTabs.newTab({
  url: url,
  activate: activate,
  position:"afterCurrrent"
});

 

1 person likes this

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0