質問するログイン新規登録

回答編集履歴

1

外だしサンプル

2018/05/01 08:47

投稿

m.ts10806
m.ts10806

スコア80888

answer CHANGED
@@ -7,4 +7,32 @@
7
7
 
8
8
  javascriptのコードがそのまま入り込んでしまっていますが、大丈夫でしょうか?
9
9
  外だしされたほうが良いかと思いますし、もしそのままonclick=""内で利用するのであれば、"がかぶっていますので正しく処理が読みこれませんね。
10
- 'に変えるなど正しく認識させる対応が必要です。
10
+ 'に変えるなど正しく認識させる対応が必要です。
11
+
12
+ # 外だしサンプル
13
+
14
+ ```html
15
+ <a href="/check_model?page=requests&model={{request.model_id}}&request={{request.id}}"
16
+    onClick='test("{{request.id}}")'>{{request.request_name}}</a>
17
+
18
+ ```
19
+ ```js
20
+
21
+ function test(requestid){
22
+ document.getElementById("div_link_"+requestid).style="display: none";
23
+ document.getElementById("div_dummy_"+requestid).style="";
24
+ }
25
+ ```
26
+ ※実際はtestではなく処理名や機能名をきちんとつけてください。
27
+
28
+
29
+ というか組んでて気づいたんですが、
30
+
31
+ ```html
32
+ <a href="/check_model?page=requests&model={{request.model_id}}&request={{request.id}}"
33
+    onClick='document.getElementById("div_link_{{request.id}}").style="display: none";
34
+  document.getElementById("div_dummy_{{request.id}}").style="";'{{request.request_name}}</a>
35
+ ```
36
+
37
+ <a>の > ←これ、ないですね。
38
+ そこが原因だったりして。