These are chat archives for opal/opal

6th
Nov 2015
Vais Salikhov
@vais
Nov 06 2015 00:25
@elia :tada: @meh got it, thanks, makes sense!
Mitch VanDuyn
@catmando
Nov 06 2015 01:32
How do you post tweets like that?
Alexandr Smirnov
@JelF
Nov 06 2015 02:26
Does lastest versions of opal provide good sourcemap support?
Mitch VanDuyn
@catmando
Nov 06 2015 02:40
since version 0.8 on, and i understand 0.9 is faster and better!
Alexandr Smirnov
@JelF
Nov 06 2015 02:41
it seems, that optimisation conflicts with either rails or our code base :(
Elia Schito
@elia
Nov 06 2015 08:55
@JelF tell me more about that! : )
@catmando pasting a tweet url is eough
Brendan Grainger
@rainkinz
Nov 06 2015 16:35
Hi All, I am playing with opal-rails and specifically this usage: https://github.com/opal/opal-rails#as-a-template but if I call render_to_string as in the example the opal create template does not seem to be called at all. Am I missing something (also is this the right place to ask about opal-rails?). Thanks
Elia Schito
@elia
Nov 06 2015 16:40

@rainkinz right place indeed! : )

Can you tell me more about the template you want to render and its path?

Brendan Grainger
@rainkinz
Nov 06 2015 16:45
sure

I have a messages_controller with the following create method:

  def create
    @message = Message.create!(message_params)
    render type: :js, locals: { messages_html: render_to_string(@message) }
    # render type: :js, locals: { messages_html: "from controller" }
  end

and a create.js.opal file in: app/views/messages/create.js.opal with the following code:

require 'opal-jquery'

Document.ready? do
  puts "Adding message #{@message}"
  Element.find('#chat').append(messages_html)
end
note that if I don’t call render_to_string in the controller the opal code is called
so I think it’s actually a rails thing, but given the example here: https://github.com/opal/opal-rails#as-a-template I thought it might work
thank you so much for your help by the way
Elia Schito
@elia
Nov 06 2015 16:52
Sorry, I don't see anything obvious, can you open an issue over at https://github.com/opal/opal-rails/issues/new ?
I'll add a spec for it and then try to find out what's wrong
Brendan Grainger
@rainkinz
Nov 06 2015 16:54

sure, by the way if I change:

render type: :js, locals: { messages_html: render_to_string(@message) }

to

render type: :js, locals: { messages_html: "from controller” }

the opal code is called. So I think it’s more of a rails thing and perhaps that I’m trying to render an erb template using render_to_string then call render again to get it to call the create.js.opal template

Elia Schito
@elia
Nov 06 2015 16:59
the interaction is really strange, gotta go now, be sure to post anything you find about it here or in the issue, thanks!
Brendan Grainger
@rainkinz
Nov 06 2015 16:59
will do. Thank you
Michał Kalbarczyk
@fazibear
Nov 06 2015 21:30
How can I get this thing work ?
# `new Websocket("ws://sdfsdf")
x = JS.global.JS['WebSocket']
JS.new(x, "ws://localhost")
#<Exception: Failed to construct 'WebSocket': Please use the 'new' operator, this DOM object constructor cannot be called as a function.>
meh.
@meh
Nov 06 2015 22:08
fazibear, is there any specific reason you don't want to use opal-browser?
it has websocket support
Michał Kalbarczyk
@fazibear
Nov 06 2015 23:04
Wish opal-browser be more modular, and not require for example paggio just to have $document.body :)
but 'WebSocket' is just example for use of JS
meh.
@meh
Nov 06 2015 23:04
fazibear, it's cherry-pickable
but do open an issue if you find it's not enough
also yeah, I don't think new was implemented properly in JS
Michał Kalbarczyk
@fazibear
Nov 06 2015 23:06
you mean cherry-pickable with git right ?