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

W12 hw #18

Merged
merged 13 commits into from Sep 25, 2020
Merged

W12 hw #18

merged 13 commits into from Sep 25, 2020

Conversation

cwc329
Copy link
Collaborator

@cwc329 cwc329 commented Sep 22, 2020

這幾週真的發生太多事了,進度整個大延宕。有一部份也是我對於作業要求都沒有看得很清楚,這個習慣應該要改掉才是。

hw1
一開始就寫錯了,我直接把 week9-11 的留言板改成 SPA。然後自己嘗試寫了爛爛的 restful API,花了很多時間還做了登入功能之後,打開範例影片卻越看越不對。在越看越不對之下,我去看後面的教學影片,才發現案情真的不單純,原來這週的留言板和後面課程有關,所以只好再做一個。

hw2
todo list 一開始也是沒看清楚需求就開始做,結果做完發現沒有做篩選功能,不過我直接把完成未完成分區了,所以篩選我就簡單做是否顯示整個分區而已。
這邊有個問題:
因為要加很多監聽器,不過我發現很多按鈕點擊事件都是用同一個父元素做事件代理,這個作業中我是每個都寫一次監聽器。不過 jQuery 的代理函式好像用 selector 去選擇很多個元素,這樣是不是就可以只要用一個監聽器就可以處理所有按鈕點擊事件,然後在 callback 中做判斷就好。如果這個做法可行可行,兩種寫法的差異在哪裡?
我自己是覺得我作業中每種按鈕都一個代理監聽的做法好像比較耗能,不知道對不對。

這週因為一開始就做一個比較複雜的 API,後來在做功能比較簡單的就比較好上手,但是還是出現很多預期以外的 bug。
還有就是因為在開發的時候會用 localhost,而做好之後又要上傳到課程的伺服器,就都不會在作業資料夾直接寫作業,會很怕如果出個差錯,檔案有個什麼問題就要全部重寫。

大概是這樣,以下是 demo 網址:

  1. w11 bulletin SPA
  2. w12 bulletin SPA
  3. todo-list

已知 bug:
w12 bulletin 的 load more 按鈕有的時候會異常顯示,會在不該出現的時候出現。

Copy link
Contributor

@ChihYang41 ChihYang41 left a comment

Choose a reason for hiding this comment

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

這幾週真的發生太多事了,進度整個大延宕。有一部份也是我對於作業要求都沒有看得很清楚,這個習慣應該要改掉才是。

沒看清楚需求真的會很想哭 XDD

因為要加很多監聽器,不過我發現很多按鈕點擊事件都是用同一個父元素做事件代理,這個作業中我是每個都寫一次監聽器。不過 jQuery 的代理函式好像用 selector 去選擇很多個元素,這樣是不是就可以只要用一個監聽器就可以處理所有按鈕點擊事件,然後在 callback 中做判斷就好。如果這個做法可行可行,兩種寫法的差異在哪裡?
我自己是覺得我作業中每種按鈕都一個代理監聽的做法好像比較耗能,不知道對不對。

這兩種寫法以目前作業來說應該沒什麼差異,效能上的差異可能是會在像是好幾千、萬個 todo,然後你幫每個 todo 的某個元素加上 eventListener 之類的,但你目前作業的寫法來說沒什麼問題的~

week12 作業看起來都沒什麼問題,簡答題回答的很好,讚讚👍

不過 week11 的留言板我沒辦法登入,console 顯示的錯誤訊息長這樣:

可以再看看哪邊出了問題~

Comment on lines +124 to +131
$('.addTodoForm').submit((e) => {
e.preventDefault();
const newTodo = $('.addTodoForm__todo').val();
const $newCard = $(unfinishedTemplate.replace('%todo', escapeHtml(newTodo)));
$('.todos__unfinished .list-group').append($newCard);
$('.addTodoForm__todo').val('');
$newCard.fadeIn();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

這邊會給的建議是可以把 eventListener 的 callback 加上命名,可以比較清楚每個區塊的任務,可能就會像是:

function addTodo() {
  // ... 新增 todo
}

$('.addTodoForm').submit(addTodo);

下面編輯、刪除也依此類推

@ChihYang41 ChihYang41 merged commit b1b6d3d into master Sep 25, 2020
@ChihYang41 ChihYang41 deleted the w12_hw branch September 25, 2020 14:50
@cwc329
Copy link
Collaborator Author

cwc329 commented Sep 25, 2020

不過 week11 的留言板我沒辦法登入,console 顯示的錯誤訊息長這樣:

可以再看看哪邊出了問題~
大概是整理 code 的時候把這個變數刪掉了,
剛剛把 demo 上面的加回去了,
不過我也不確定這樣是不是就修好了QQ

cwc329 pushed a commit that referenced this pull request Nov 3, 2020
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.

None yet

2 participants