When I am sending the properties as name, value the name is sent as "name" instead of the argument value of name. Is there a fix for it? Right now I use case to send in right way.
/**
* Change properties of the elements
*/
this.changeProperties = function(type,value) {
switch(type)
{
case "stroke":
$.DrawEngine.changeProperties({"stroke":value});
break;
case "font-family":
$.DrawEngine.changeProperties({"font-family":value});
break;
}
};
this.changeProperties = function(type,value) {
$.DrawEngine.changeProperties({"stroke":value});
}
it sends {type:"red"}
instead of {"stroke": "red"}
You probably need to pass it as
this.changeProperties = function(type,value) {
var obj = {};
obj[type] = value;
$.DrawEngine.changeProperties(obj);
}
if you had been trying to add the object as {type:value}
. key is not evaluated as type's actual value instead it becomes the key itself. So you would need to use array notation to insert the value of type being created as the key.
See this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.