Reputation: 3878
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"}
Upvotes: 0
Views: 46
Reputation: 123739
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
Upvotes: 1