Reputation: 3271
Ok I'm not sure if I worded the title correctly, I wasn't really able to describe as a title what I'm trying to do.
I'm writing a plugin for my work and I have a path specified in an object literal notation like so
var options = {
jwPath: "/jwplayer/",
mediaPath: "/media/",
skin: "",
fileName: "mms"
};
So I have my options there next I'm trying to load a plugin into jwplayer using some of these parameters which isn't working, it may just be something little I'm over looking but I'm trying to load the plugin by doing the follow
plugins : {
options.jwPath + 'plugins/hd/hd.js' : {
file: options.mediaPath + options.fileName + '-hd.mp4'
}
}
I keep getting an error on the options.jwPath portion of the code. Any ideas? Is it just something little I'm overlooking?
Upvotes: 0
Views: 122
Reputation: 324650
You can't use an expression for a property name when creating an object literal. Instead, use tmpobj = {}
and then add tmpobj[options.jwPath+'plugins/hd/hd.js'] = {file:....};
. Finally, use plugins:{tmpobj}
.
Upvotes: 0
Reputation: 82614
You can't do it like that:
var options = {
jwPath: "/jwplayer/",
mediaPath: "/media/",
skin: "",
fileName: "mms"
};
var plugins = {};
plugins[options.jwPath + 'plugins/hd/hd.js'] = {
file: options.mediaPath + options.fileName + '-hd.mp4'
};
But bracket notation will work.
Upvotes: 2