質問編集履歴

2

追記

2016/02/23 06:08

投稿

yadrop
yadrop

スコア57

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,9 @@
44
44
 
45
45
 
46
46
 
47
+ ```
48
+
47
- ```product_result.js
49
+ product_result.js
48
50
 
49
51
 
50
52
 
@@ -82,7 +84,9 @@
82
84
 
83
85
 
84
86
 
87
+ ```
88
+
85
- ```search.js
89
+ search.js
86
90
 
87
91
 
88
92
 

1

コード追記

2016/02/23 06:08

投稿

yadrop
yadrop

スコア57

test CHANGED
File without changes
test CHANGED
@@ -29,3 +29,81 @@
29
29
 
30
30
 
31
31
  何卒、宜しくお願いします。
32
+
33
+
34
+
35
+ -------- 追記 ----------
36
+
37
+
38
+
39
+
40
+
41
+ テンプレートが以下になります。
42
+
43
+ この中で、商品リストを回しながらshouhin_cdとcolor_cdを使用したいです。
44
+
45
+
46
+
47
+ ```product_result.js
48
+
49
+
50
+
51
+ var tmpl_product_result = '\
52
+
53
+ <div class="productWrapper">\
54
+
55
+ <div class="productImage">\
56
+
57
+ <a href="/Products/<%= shouhin_cd %>/<%= color_cd %>/?from_search=1">\
58
+
59
+ <img class="angle_change_target"\
60
+
61
+ num1="<%= image_url_01 %>"\
62
+
63
+ num2="<%= image_url_02 %>"\
64
+
65
+ num3="<%= image_url_03 %>"\
66
+
67
+ src="<%= image_url %>"\
68
+
69
+ alt="<%= shouhin_cd %>-<%= iro_cd %>" />\
70
+
71
+ </a>\
72
+
73
+ </div>\
74
+
75
+ </div>';
76
+
77
+ ```
78
+
79
+
80
+
81
+ 下記が読み込んでいるファイルのようで、処理後にhtmlを返却しているようです。
82
+
83
+
84
+
85
+ ```search.js
86
+
87
+
88
+
89
+ document.write('<script src="templates/product_result.js" type="text/javascript"></script>');
90
+
91
+
92
+
93
+ var refresh = function(products){
94
+
95
+ var tmpl_result = _.template(tmpl_product_result);
96
+
97
+ var html = "";
98
+
99
+ _.each(products,function(num){
100
+
101
+ html += tmpl_result(num);
102
+
103
+ });
104
+
105
+ return html;
106
+
107
+ };
108
+
109
+ ```