0

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.

Working one

/**
     * 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;
        }
    };

Not working one

    this.changeProperties = function(type,value) {
            $.DrawEngine.changeProperties({"stroke":value});
}

Reason

it sends {type:"red"} instead of {"stroke": "red"}

2
  • How are you calling the not working one? Commented Jul 2, 2013 at 1:54
  • I have tried first not working one, as it is not working I am using switch which I want to avoid it Commented Jul 2, 2013 at 1:55

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.