如何在 juggernaut 中实现文本输入部分和发送按钮?

发布于 2024-11-30 18:30:20 字数 209 浏览 1 评论 0 原文

我已经遵循了 github 上的确切指南,并且正在执行最后一步:

“就是这样!现在转到 http://localhost:8080 观看剑圣的行动。”

将显示一个对话框。但是,我无法写任何文字。

我希望能够修复该页面以供实际聊天使用,而不仅仅是测试。

I have followed the exact guidelines on github and I am on the final step of:

"That's it! Now go to http://localhost:8080 to see Juggernaut in action."

A dialog box is displayed. However, I am unable to write any text.

I would like to be able to fix up the page for practical chat usage instead of just testing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧时模样 2024-12-07 18:30:20

看来您需要遵循 Juggernaut 自述文件中标题为“基本用法”的行下的指南。

基本用法

Juggernaut 中的一切都是在通道的上下文中完成的。
JavaScript 客户端可以订阅您的服务器可以订阅的频道
发布到.首先,我们需要包含 Juggernaut 的 application.js
文件。默认情况下,Juggernaut 托管在端口 8080 上 - 所以我们可以
链接到那里的文件。

完成此操作后,您可以在控制器中实现上面提到的 Ruby 代码,该控制器从表单获取用户输入,然后调用类似 Juggernaut.publish("channel1", @user_data) 的内容,从而允许您的用户通过服务器向对方发送数据。
`

It looks like you need to follow the guide on the Juggernaut readme under that line titled Basic Usage.

Basic usage

Everything in Juggernaut is done within the context of a channel.
JavaScript clients can subscribe to a channel which your server can
publish to. First, we need to include Juggernaut's application.js
file. By default, Juggernaut is hosted on port 8080 - so we can just
link to the file there.

<script src="http://localhost:8080/application.js"

type="text/javascript" charset="utf-8">

We then need to instantiate the Juggernaut object and subscribe to the
channel. As you can see, subscribe takes two arguments, the channel
name and a callback.

<script type="text/javascript" charset="utf-8">
  var jug = new Juggernaut;
  jug.subscribe("channel1", function(data){
    console.log("Got data: " + data);
  });
</script>

That's it for the client side. Now, to publish to the channel we'll
write some Ruby:

require "juggernaut"
Juggernaut.publish("channel1", "Some data")

You should see the data we sent appear instantly in the open browser
window. As well as strings, we can even pass objects, like so:

Juggernaut.publish("channel1", {:some => "data"})

The publish method also takes an array of channels, in case you want
to send a message to multiple channels co-currently.

Juggernaut.publish(["channel1", "channel2"], ["foo", "bar"])

That's pretty much the gist of it, the two methods - publish and
subscribe. Couldn't be easier than that!

Once you have that done you can implement the Ruby code mentioned above inside a controller which takes the user input from a form and then calls something like Juggernaut.publish("channel1", @user_data) allowing your users to send data through the server to each other.
`

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文