I am trying to call some jQuery functions from C++ code. What I did was copy the entire jQuery library as a string and used jsc_context_evaluate() to get access to all the jQuery methods.
Here is an unspecific stripped-down version with a string, it works fine:
JSCValue* jsVar = jsc_context_evaluate(jsCtx, "$('some-div')");
jsc_value_object_invoke_method(jsVar, "html", G_TYPE_STRING, "foo", G_TYPE_NONE);
This changes the contents of 'some-div' to just "foo". (I know 'some-div' should really have a '.' or '#' but it is just for representation)
When I try to use an object, the function doesn't work.
JSCValue* jsVar = jsc_context_evaluate(jsCtx, "$('some-div')");
JSCValue* jsDiv = jsc_context_evaluate(jsCtx, "$('some-other-div')");
jsc_value_object_invoke_method(jsVar, "html", G_TYPE_OBJECT, jsDiv, G_TYPE_NONE);
Instead of 'some-div' getting the content of 'some-other-div', nothing happens. When I print the return value of ...invoke_method()
as a string with jsc_value_to_string()
I get undefined. I tried it with other jQuery methods like add
but it's the same result, the function returns undefined and nothing changes.