7

I'm having a problem since I wrapped my javascript functions inside of a namespace. Version 1 of my code worked fine. Originally, to call the javascript from inside Silverlight I used to use this code:

HtmlPage.Window.Invoke("hideMyDiv");

My javascript looked like this:

function hideMyDiv() {
$('#MyDiv').fadeOut();

}

Now, I've refactored my javascript to be contained in a namespace. So it now looks like this:

var activity = {
message: null,
hideMyDiv: function() {
    $('#MyDiv').fadeOut();
}   };

I can call this refactored function in javascript, it works like before:

$("document").ready(function() {
activity.hideMyDiv();   });

But when I try to use it from Silverlight, I get this error: Failed to Invoke: activity.updateInfo. This is my current Silverlight code:

HtmlPage.Window.Invoke("activity.hideMyDiv");

What am I doing wrong? (and thanks!)

1 Answer 1

12

This is the correct way..

ScriptObject so = HtmlPage.Window.Eval("activity") as ScriptObject;
so.Invoke("hideMyDiv");
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.