Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

slimでjQueryを複数行書く

More than 1 year has passed since last update.

概要

erbをslim化するにあたって少々詰まったのでメモ

コード

| $("#hogehoge_#{@hoge.id}").html("
= escape_javascript(render partial: 'hogehoge/fuga_form', locals: { hoge: @hoge } )
| ");

| $("#hoge_with_fuga_#{@hoge.id}").remove();

解説

rubyコードを =で書いて純粋なjQueryはパイプを使用しました。
思ったよりハマったのは、erbのときはけつに ; がなくても通ったが、
slimの場合は、2行に渡す場合は必ず最後に ; をつけないとSyntax errorで怒られた。

suzuki-r
Railsをメインで書いてまーす!
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away