Sean Clark Hess
2008-Aug-22 18:06 UTC
[Ironruby-core] Passing a callback to ScriptObject.Invoke
Hi everybody, I''m plugging in to an existing javascript library using invoke. I can successfully call my_js_object.invoke and get it to call different functions. They implemented a function called Observe that accepts a callback (event system). How can I tie in to javascript events with ruby? I can pass values, like js_object.invoke "Observe","EventName", but it doesn''t really work to put a block as the last (the callback) parameter. Any ideas? How can I do this? Thanks ~sean -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080822/db69111e/attachment.html>
Tomas Matousek
2008-Aug-22 20:21 UTC
[Ironruby-core] Passing a callback to ScriptObject.Invoke
Can you send a small example of what you''re trying to do? Is it browser native JavaScript or managed DLR JScript? Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Sean Clark Hess Sent: Friday, August 22, 2008 11:06 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Passing a callback to ScriptObject.Invoke Hi everybody, I''m plugging in to an existing javascript library using invoke. I can successfully call my_js_object.invoke and get it to call different functions. They implemented a function called Observe that accepts a callback (event system). How can I tie in to javascript events with ruby? I can pass values, like js_object.invoke "Observe","EventName", but it doesn''t really work to put a block as the last (the callback) parameter. Any ideas? How can I do this? Thanks ~sean -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080822/f5060bfc/attachment-0001.html>
Sean Clark Hess
2008-Aug-22 20:23 UTC
[Ironruby-core] Passing a callback to ScriptObject.Invoke
sure, I''ll cook one up really quick On Fri, Aug 22, 2008 at 2:21 PM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote:> Can you send a small example of what you''re trying to do? Is it browser > native JavaScript or managed DLR JScript? > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Sean Clark Hess > *Sent:* Friday, August 22, 2008 11:06 AM > *To:* ironruby-core at rubyforge.org > *Subject:* [Ironruby-core] Passing a callback to ScriptObject.Invoke > > > > Hi everybody, > > > > I''m plugging in to an existing javascript library using invoke. I can > successfully call my_js_object.invoke and get it to call different > functions. > > > > They implemented a function called Observe that accepts a callback (event > system). How can I tie in to javascript events with ruby? I can pass > values, like js_object.invoke "Observe","EventName", but it doesn''t really > work to put a block as the last (the callback) parameter. > > > > Any ideas? How can I do this? > > > > 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/20080822/a9fe4a0b/attachment.html>
Sean Clark Hess
2008-Aug-22 20:42 UTC
[Ironruby-core] Passing a callback to ScriptObject.Invoke
Ok, I put the following in index.html in a blank ruby dynamic silverlight project http://pastie.textmate.org/258247 This is a really simple event system, with only one event, one listener... etc. It has a default handler you can trigger by clicking the link. Then, here is app.rb http://pastie.textmate.org/258249 Uncomment line 10 to see that you have a handle on the js object. Line 11, however, throws an error no matter what I do. Basically, I want to be able to pass a block of ruby code to be executed whenever the javascript function is called. I know I can use the HTML stuff to listen for a click directly, but I''m trying to plug into a js system that dispatches events this way, so I can''t change the js interface. Thanks for your help, and let me know if you have any more questions. ~sean On Fri, Aug 22, 2008 at 2:23 PM, Sean Clark Hess <seanhess at gmail.com> wrote:> sure, I''ll cook one up really quick > > On Fri, Aug 22, 2008 at 2:21 PM, Tomas Matousek < > Tomas.Matousek at microsoft.com> wrote: > >> Can you send a small example of what you''re trying to do? Is it browser >> native JavaScript or managed DLR JScript? >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Sean Clark Hess >> *Sent:* Friday, August 22, 2008 11:06 AM >> *To:* ironruby-core at rubyforge.org >> *Subject:* [Ironruby-core] Passing a callback to ScriptObject.Invoke >> >> >> >> Hi everybody, >> >> >> >> I''m plugging in to an existing javascript library using invoke. I can >> successfully call my_js_object.invoke and get it to call different >> functions. >> >> >> >> They implemented a function called Observe that accepts a callback (event >> system). How can I tie in to javascript events with ruby? I can pass >> values, like js_object.invoke "Observe","EventName", but it doesn''t really >> work to put a block as the last (the callback) parameter. >> >> >> >> Any ideas? How can I do this? >> >> >> >> 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/20080822/43b3e1b1/attachment.html>
Jimmy Schementi
2008-Aug-25 23:32 UTC
[Ironruby-core] Passing a callback to ScriptObject.Invoke
Sean, I?ll make sure to get back to you. I can run a ruby block given a Javascript event, but I?ll cook up a app that does what you ask shortly. Let me know if this is urgent, and I?ll do it faster =) On 8/22/08 1:42 PM, "Sean Clark Hess" <seanhess at gmail.com> wrote: Ok, I put the following in index.html in a blank ruby dynamic silverlight project http://pastie.textmate.org/258247 This is a really simple event system, with only one event, one listener... etc. It has a default handler you can trigger by clicking the link. Then, here is app.rb http://pastie.textmate.org/258249 Uncomment line 10 to see that you have a handle on the js object. Line 11, however, throws an error no matter what I do. Basically, I want to be able to pass a block of ruby code to be executed whenever the javascript function is called. I know I can use the HTML stuff to listen for a click directly, but I''m trying to plug into a js system that dispatches events this way, so I can''t change the js interface. Thanks for your help, and let me know if you have any more questions. ~sean On Fri, Aug 22, 2008 at 2:23 PM, Sean Clark Hess <seanhess at gmail.com> wrote: sure, I''ll cook one up really quick On Fri, Aug 22, 2008 at 2:21 PM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote: Can you send a small example of what you''re trying to do? Is it browser native JavaScript or managed DLR JScript? Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Sean Clark Hess Sent: Friday, August 22, 2008 11:06 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Passing a callback to ScriptObject.Invoke Hi everybody, I''m plugging in to an existing javascript library using invoke. I can successfully call my_js_object.invoke and get it to call different functions. They implemented a function called Observe that accepts a callback (event system). How can I tie in to javascript events with ruby? I can pass values, like js_object.invoke "Observe","EventName", but it doesn''t really work to put a block as the last (the callback) parameter. Any ideas? How can I do this? 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/20080825/26a23507/attachment.html>
Really? That would be awesome. Realize though, that I need it to work for custom callbacks, not for any standard ha event. Thanks! Yeah, we kind if tabled the project because it was taking so long, but I''d love to know the answer On Aug 25, 2008, at 5:32 PM, Jimmy Schementi <Jimmy.Schementi at microsoft.com > wrote:> Sean, I?ll make sure to get back to you. I can run a ruby block give > n a Javascript event, but I?ll cook up a app that does what you ask > shortly. Let me know if this is urgent, and I?ll do it faster =) > > > On 8/22/08 1:42 PM, "Sean Clark Hess" <seanhess at gmail.com> wrote: > > Ok, I put the following in index.html in a blank ruby dynamic > silverlight project > > http://pastie.textmate.org/258247 > > > > This is a really simple event system, with only one event, one > listener... etc. It has a default handler you can trigger by > clicking the link. > > > > Then, here is app.rb > > > > http://pastie.textmate.org/258249 > > > > Uncomment line 10 to see that you have a handle on the js object. > Line 11, however, throws an error no matter what I do. > > > > Basically, I want to be able to pass a block of ruby code to be > executed whenever the javascript function is called. > > > > I know I can use the HTML stuff to listen for a click directly, but > I''m trying to plug into a js system that dispatches events this way, > so I can''t change the js interface. > > > > Thanks for your help, and let me know if you have any more questions. > > > > ~sean > > > On Fri, Aug 22, 2008 at 2:23 PM, Sean Clark Hess > <seanhess at gmail.com> wrote: > sure, I''ll cook one up really quick > > On Fri, Aug 22, 2008 at 2:21 PM, Tomas Matousek <Tomas.Matousek at microsoft.com > > wrote: > Can you send a small example of what you''re trying to do? Is it > browser native JavaScript or managed DLR JScript? > > > > Tomas > > > > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org > ] On Behalf Of Sean Clark Hess > Sent: Friday, August 22, 2008 11:06 AM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] Passing a callback to ScriptObject.Invoke > > > > Hi everybody, > > > > I''m plugging in to an existing javascript library using invoke. I > can successfully call my_js_object.invoke and get it to call > different functions. > > > > They implemented a function called Observe that accepts a callback > (event system). How can I tie in to javascript events with ruby? I > can pass values, like js_object.invoke "Observe","EventName", but it > doesn''t really work to put a block as the last (the callback) > parameter. > > > > Any ideas? How can I do this? > > > > Thanks > > ~sean > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > _______________________________________________ > 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/20080825/bafe5733/attachment.html>