質問編集履歴

4

誤字

2024/11/13 12:53

投稿

kicchi82
kicchi82

スコア3

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  export default class extends Controller {
46
46
  static targets = ["placeholder", "pointsDataReciever"]
47
- static values = { points: Object }
47
+ static values = { points: String }
48
48
 
49
49
  connect() {
50
50
  console.log (this.pointsValue);

3

コードの追加

2024/11/13 12:42

投稿

kicchi82
kicchi82

スコア3

test CHANGED
File without changes
test CHANGED
@@ -32,13 +32,18 @@
32
32
  data-map-target="pointsDataReciever"
33
33
  data-map-points-value="<%= @point1.to_json %>">
34
34
  </div>
35
+
36
+ <div class="leaflet-container" data-controller="map"
37
+ data-map-target="placeholder"
38
+ style="height: 800px; width: 800px;">
39
+ </div>
35
40
  ```
36
41
 
37
42
  ```map_contoroller.js
38
43
  import { Controller } from "@hotwired/stimulus";
39
44
 
40
45
  export default class extends Controller {
41
- static targets = ["pointsDataReciever"]
46
+ static targets = ["placeholder", "pointsDataReciever"]
42
47
  static values = { points: Object }
43
48
 
44
49
  connect() {

2

誤字

2024/11/13 08:31

投稿

kicchi82
kicchi82

スコア3

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
  {"id":1,"post_id":4,"title":"ほげほげ","content":"ほげほげ","position":1,"lat":"35.689481","lng":"139.691686","country_id":153,"prefecture_id":35,"created_at":"2024-11-06T12:47:10.620Z","updated_at":"2024-11-12T01:34:57.561Z"}
15
15
 
16
16
  その上で、stimulusのmap_controllerで、
17
- console.log(this,pointsValue)としたのですが、
17
+ console.log(this.pointsValue)としたのですが、
18
18
  コンソールには
19
19
  _{ }_
20
20
  としか表示されません。

1

誤字

2024/11/13 08:29

投稿

kicchi82
kicchi82

スコア3

test CHANGED
File without changes
test CHANGED
@@ -28,7 +28,10 @@
28
28
  ### 該当のソースコード
29
29
 
30
30
  ```posts/show.html.erb
31
- <div id="data-reciever" data-controller="map" data-map-target="pointsDataReciever" data-map-points-value="<%= @point1.to_json %>"></div>
31
+ <div id="data-reciever" data-controller="map"
32
+ data-map-target="pointsDataReciever"
33
+ data-map-points-value="<%= @point1.to_json %>">
34
+ </div>
32
35
  ```
33
36
 
34
37
  ```map_contoroller.js