Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

week7 homework #15

Merged
merged 1 commit into from
Oct 22, 2018
Merged

week7 homework #15

merged 1 commit into from
Oct 22, 2018

Conversation

futianshen
Copy link
Collaborator

@futianshen futianshen commented Oct 21, 2018

Week7 作業三,在完成 AJAX 功能之後,才使用 Bootstrap 修改版面,因為更動了 HTML 結構,所以有兩個版本。

本週完成事項

@@ -58,7 +55,7 @@
<div class="btn btn-success todo__done">完成</div>
<div class="btn btn-danger todo__delete">刪除</div>
</div>
</li>` // 為什麼這邊要用 ` ${}是 jQuery 的獨有用法嗎?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這問題沒看懂,不確定你在問哪裡XD

@@ -78,7 +75,7 @@
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">Add new todo</span>
</div>
<input type="text" required="required" class="form-control add-todo" placeholder="todo" aria-label="todo" aria-describedby="basic-addon1"><!-- aria 無障礙設計 --> <!-- 為什麼 requried 沒有用? -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因為這不是個表單,所以 required 沒用

$comment_nickname=$read_comment_row['nickname'];
$comment_time=$read_comment_row['created_at'];
$comment_id = $read_comment_row['id'];
$conn->close(); //這個的作用是什麼? 沒 close 會怎麼樣?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

就有些資源會多留一陣子才被釋放

type: "POST",
url: 'comment.php',
data: {
comment_content: comment_content,/* 會不會有 XSS 的問題? */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你只要 render 的時候有先 escape 就不會

@aszx87410
Copy link
Member

都沒什麼問題,你卡關的那個問題你可以想想以下範例:

$('.test').click(function(){
  alert('test')
})
$('body').append('<div class="test">click me</div>')

程式是按照順序跑的,所以你在跑第一行的時候,$('.test') 的回傳是 null,因為那時候還沒有任何元素。因此你新增的按鈕當然不會有反應,因為根本沒有 eventListener 加上去

解法就是你查到的那個,用 on 來代替,這叫做 event delegation。

@aszx87410 aszx87410 merged commit b01075a into master Oct 22, 2018
@aszx87410 aszx87410 deleted the week7 branch October 22, 2018 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants