1 Replies - 479 Views - Last Post: 23 November 2015 - 09:32 AM

#1 Subalee   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 63
  • Joined: 08-September 13

Infamous to-do list project, need help with planning

Posted 21 November 2015 - 09:18 AM


I've recently decided I'll brush up on JS, I'd like to become, well not JS ninja, maybe at least a student of ninja :D.

I have some grasp on OOP, so I'd like to go that route.

What i need help with is the thought process

for now the project won't have any "storage" i.e not html5 storage, database or anything of that type, though it would be great to learn that as well.

right now, in order of simplifying it a little there will be only one to do list.

I have a class Task, which has a property of title, (later on maybe i'll add something else like priority, due date, subnotes, category etc.)

On the "frontend" i have input box with submit button, which appends <li> to <ul>. The content of li is the title (set from the input using setter method) of newly created instance of class Task, which is pushed to array.

Is this so far valid approach?

I haven't tried doing the removal yet, What i do is that i also append <a> with class of close, that i will use to remove the particular task in the <ul>
However what i find trouble some is the removal itself. My idea of doing it is that i would again have a function that would remove the object from the array using .pop() (will this delete the instance ?) and remove the parent <li> of that particular <a>

Is this correct or not?

As for other lists i guess that would be just another objcets, but what i struggle with is how would i go about adding the same task into several other lists. Let's say i have list of all tasks and i create a list called school, which will have some of the tasks that are inside the all, however if i create the task inside the school list i want it to be inside all list as well.

I hope it's not too weird, that i didn't actually paste anycode in here, right now I'm in a state where i'm just prototyping with really ugly code, that i will most likely rewrite from scratch

Thanks for the tips!

Is This A Good Question/Topic? 0
  • +

Replies To: Infamous to-do list project, need help with planning

#2 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2206
  • View blog
  • Posts: 6,660
  • Joined: 15-January 14

Re: Infamous to-do list project, need help with planning

Posted 23 November 2015 - 09:32 AM

The things that you're describing won't all happen automatically (i.e., you'll have to add the task to all lists that you want it to be in yourself), and keep in mind that the DOM isn't connected with your array of objects. So you might have a function to add a task that will add it to the array and also update the page, those are 2 separate steps that your function would take. Likewise, with removal you would manually remove the element and also remove it from the array.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1