[Notice] Announcing the End of Demo Server [Read me]

add javascript vaildate in board
@a821101f12e74ced2955e00e930d4ed6caedc9a2
--- app/views/board/editPost.scala.html
+++ app/views/board/editPost.scala.html
... | ... | @@ -4,6 +4,10 @@ |
4 | 4 |
@implicitFieldConstructor = @{ helper.FieldConstructor(twitterBootstrapInput.render) } |
5 | 5 |
|
6 | 6 |
@main(title, project) { |
7 |
+ <div id="warning" class="hide alert"> |
|
8 |
+ <button class="close" >×</button> |
|
9 |
+ <strong>@Messages("message.warning")</strong> 제목과 본문에 빈칸이 있습니다. |
|
10 |
+ </div> |
|
7 | 11 |
@helper.form(action=routes.BoardApp.updatePost(project.owner, project.name, postId), 'enctype -> "multipart/form-data"){ |
8 | 12 |
@helper.inputText(form("title"), '_showConstraints -> false, '_label-> Messages("post.new.title")) |
9 | 13 |
@helper.textarea(form("contents"), '_showConstraints -> false, '_label-> Messages("post.new.contents")) |
... | ... | @@ -11,7 +15,5 @@ |
11 | 15 |
<input type="submit" class="btn btn-primary" value="@Messages("button.save")"/> |
12 | 16 |
<input type="reset" class="btn" value="@Messages("button.reset")"/> |
13 | 17 |
} |
14 |
- @*@postVaildate()*@ |
|
18 |
+ <script>nforge.require("board.vaildate");</script> |
|
15 | 19 |
} |
16 |
- |
|
17 |
-(No newline at end of file) |
--- app/views/board/newPost.scala.html
+++ app/views/board/newPost.scala.html
... | ... | @@ -4,6 +4,10 @@ |
4 | 4 |
@implicitFieldConstructor = @{ helper.FieldConstructor(twitterBootstrapInput.render) } |
5 | 5 |
|
6 | 6 |
@main(title, project) { |
7 |
+ <div id="warning" class="hide alert"> |
|
8 |
+ <button class="close" >×</button> |
|
9 |
+ <strong>@Messages("message.warning")</strong> 제목과 본문에 빈칸이 있습니다. |
|
10 |
+ </div> |
|
7 | 11 |
@helper.form(action=routes.BoardApp.savePost(project.owner, project.name), 'enctype -> "multipart/form-data"){ |
8 | 12 |
@helper.inputText(form("title"), '_showConstraints -> false, '_label-> Messages("post.new.title")) |
9 | 13 |
@helper.textarea(form("contents"), '_showConstraints -> false, '_label-> Messages("post.new.contents")) |
... | ... | @@ -11,5 +15,5 @@ |
11 | 15 |
<input type="submit" class="btn btn-primary" value="@Messages("button.save")"/> |
12 | 16 |
<input type="reset" class="btn" value="@Messages("button.reset")"/> |
13 | 17 |
} |
14 |
- @*@postVaildate()*@ |
|
18 |
+ <script>nforge.require("board.vaildate");</script> |
|
15 | 19 |
} |
--- app/views/board/postVaildate.scala.html
+++ app/views/board/postVaildate.scala.html
... | ... | @@ -11,4 +11,18 @@ |
11 | 11 |
<a href="#" class="btn" data-dismiss="modal">확인</a> |
12 | 12 |
</div> |
13 | 13 |
</div> |
14 |
-<script>nforge.require("board.vaildate");</script>(No newline at end of file) |
|
14 |
+<script> |
|
15 |
+$(document).ready(function(){ |
|
16 |
+ $("form").submit(function(){ |
|
17 |
+ if($("input#title").val() == "" || $("textarea#contents").val() == "") |
|
18 |
+ { |
|
19 |
+ $('#chk_vaildate').modal() |
|
20 |
+ return false; |
|
21 |
+ } |
|
22 |
+ else |
|
23 |
+ { |
|
24 |
+ return true; |
|
25 |
+ } |
|
26 |
+ }); |
|
27 |
+}); |
|
28 |
+</script>(No newline at end of file) |
--- public/javascripts/modules/board.js
+++ public/javascripts/modules/board.js
... | ... | @@ -1,54 +1,54 @@ |
1 | 1 |
nforge.namespace("board"); |
2 | 2 |
nforge.board.list = function() { |
3 |
- var that = { |
|
4 |
- init : function() { |
|
5 |
- that.setUpEventListener(); |
|
6 |
- }, |
|
7 |
- setUpEventListener : function() { |
|
8 |
- var $headers = $("th a"); |
|
9 |
- $headers.click(that.onHeader); |
|
10 |
- var $pagination = $("pagination a"); |
|
11 |
- $pagination.click(that.onPager); |
|
12 |
- }, |
|
13 |
- onHeader : function() { |
|
14 |
- var key = $(this).attr("key"); |
|
15 |
- var $input = $("#search-form input[name=key]"); |
|
16 |
- if (key !== $input.val()) { |
|
17 |
- $input.val(key) |
|
18 |
- } else { |
|
19 |
- $input = $("#search-form input[name=order]"); |
|
20 |
- if ($input.val() === "desc") |
|
21 |
- $input.val("asc"); |
|
22 |
- else if ($input.val() === "asc") |
|
23 |
- $input.val("desc"); |
|
24 |
- } |
|
25 |
- $("#search-form").submit(); |
|
26 |
- return false; |
|
27 |
- }, |
|
28 |
- onPager : function() { |
|
29 |
- var $input = $("#search-form input[name=pageNum]"); |
|
30 |
- $input.val($(this).attr("pageNum")); |
|
31 |
- $("#search-form").submit(); |
|
32 |
- return false; |
|
33 |
- } |
|
34 |
- }; |
|
35 |
- return that; |
|
3 |
+ var that = { |
|
4 |
+ init : function() { |
|
5 |
+ that.setUpEventListener(); |
|
6 |
+ }, |
|
7 |
+ setUpEventListener : function() { |
|
8 |
+ var $headers = $("th a"); |
|
9 |
+ $headers.click(that.onHeader); |
|
10 |
+ var $pagination = $("pagination a"); |
|
11 |
+ $pagination.click(that.onPager); |
|
12 |
+ }, |
|
13 |
+ onHeader : function() { |
|
14 |
+ var key = $(this).attr("key"); |
|
15 |
+ var $input = $("#search-form input[name=key]"); |
|
16 |
+ if (key !== $input.val()) { |
|
17 |
+ $input.val(key) |
|
18 |
+ } else { |
|
19 |
+ $input = $("#search-form input[name=order]"); |
|
20 |
+ if ($input.val() === "desc") |
|
21 |
+ $input.val("asc"); |
|
22 |
+ else if ($input.val() === "asc") |
|
23 |
+ $input.val("desc"); |
|
24 |
+ } |
|
25 |
+ $("#search-form").submit(); |
|
26 |
+ return false; |
|
27 |
+ }, |
|
28 |
+ onPager : function() { |
|
29 |
+ var $input = $("#search-form input[name=pageNum]"); |
|
30 |
+ $input.val($(this).attr("pageNum")); |
|
31 |
+ $("#search-form").submit(); |
|
32 |
+ return false; |
|
33 |
+ } |
|
34 |
+ }; |
|
35 |
+ return that; |
|
36 | 36 |
}; |
37 | 37 |
nforge.board.vaildate = function() { |
38 |
- var that = { |
|
39 |
- init : function(){ |
|
40 |
- $("form").submit(function(){ |
|
41 |
- if($("input#title").val() == "" || $("textarea#contents").val() == "") |
|
42 |
- { |
|
43 |
- $('#chk_vaildate').modal() |
|
44 |
- return false; |
|
45 |
- } |
|
46 |
- else |
|
47 |
- { |
|
48 |
- return true; |
|
49 |
- } |
|
50 |
- }); |
|
51 |
- } |
|
52 |
- }; |
|
53 |
- return that; |
|
38 |
+ var that = { |
|
39 |
+ init : function() { |
|
40 |
+ $("form").submit(function() { |
|
41 |
+ if ($("input#title").val() == "" || $("textarea#contents").val() == "") { |
|
42 |
+ $("#warning button").click(function(){ |
|
43 |
+ $('#warning').hide(); |
|
44 |
+ }); |
|
45 |
+ $('#warning').show(); |
|
46 |
+ return false; |
|
47 |
+ } else { |
|
48 |
+ return true; |
|
49 |
+ } |
|
50 |
+ }); |
|
51 |
+ } |
|
52 |
+ }; |
|
53 |
+ return that; |
|
54 | 54 |
}(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?