[Ironruby-core] ScriptableMember and Silverlight

Sean Clark Hess seanhess at gmail.com
Thu Aug 14 16:00:03 EDT 2008


Sweet... I just figured out how to call a js function from ruby, and in
fact, that works better for what I want to do anyway.
Thanks!


On Thu, Aug 14, 2008 at 1:44 PM, Jimmy Schementi <
Jimmy.Schementi at microsoft.com> wrote:

>  Hey Sean,
>
> Yeah, I'm well aware of the issue with not being able to use
> [ScriptableMember] for IronRuby. =(
>
> 1. Access Javascript variable from Ruby:
>
> If in your HTML you have some variable:
> <script type="text/javascript">
>   var jsVar = "Hello from Javascript"
> </script>
>
> Then in your Ruby script you can access it:
>
> Include System::Windows::Browser
> HtmlPage.window.eval "jsVar"
>
> 2.  Access Ruby function from Javascript
>
> This is not directly possible because of not having attribute support. Curt
> might have more input into whether this will be fixed in the future.
>
> However, if you're not opposed to hacky solutions, attach Ruby to a JS
> event (HtmlElement#attach_event), and when you want data from Ruby fire the
> JS event and Ruby could write the data to the DOM (a hidden div, perhaps?).
> Ugh, that sucks, but it's what we've got today.
>
> I'd suggest trying the first option, and we'll keep you posted on making
> Ruby objects scriptable from JS.
>
> ~js
>
>
>
> On 8/14/08 11:59 AM, "Sean Clark Hess" <seanhess at gmail.com> wrote:
>
> Hello all,  I need some way to either access a javascript variable or
> expose a function to javascript to be called later.  I've tried option #2,
> with the following call, but I don't know how to specify a member function
> as scriptable.  In C#, you use a meta-flag [ScriptableMember] above the
> function.
>
> HtmlPage.register_scriptable_object('mn', self)
>
> What about the other approach?  I know you can access the dom, but I need
> to access a plain old variable from javascript.
>
> Thanks!
> ~sean
>
>
>
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080814/4b5ac5d3/attachment-0001.html>


More information about the Ironruby-core mailing list