Homework 8 (To-Do List) FAQ

Q: If I do the Ajax search feature, do I still need a "back" link like it says in the spec?
A: You should have some kind of link to restore the page to its original state.
Q: When i tried to file_put_contents("todolist.txt", $go[1]); the permission is denied even though i have set the permission in the webster to be ok to write, so how could i get the permission to write in the file. And i also tried the fopen ("todolist.txt", 'w+'); and it does not work too.
A: Did you say okay to write to the FILE, or the Homework folder itself? Because there's a definite difference and I've had a problem with that before. Make sure you have checked the boxes for the Write permissions on the file, and if that doesn't work, make sure that your directory for the assignment (hw8) has write and execute permissions turned on. Execute permission on a directory allows someone to enter that directory and view its contents. If you are getting "permission denied" messages, try changing the read/write permissions on your hw8 folder in Webster.
Q: My to-do list grows in width to accommodate the long item, I tried to have the list items have a max width and then set the overflow property, and none of the overflow properties achieves what I need.
A: Just setting a width for the overall list should do what you want.
Q: My Ajax requests aren't working. When I debug them in Firebug's Net tab, I see "OPTIONS" and an XML processing error. Why?
A: This happens when you're requesting an HTTPS URL from a regular HTTP site or vice versa. It's probably that you put a complete URL such as "http://webster..." in your code rather than just a relative path. Or change your URL in your code to say "https" rather than "http" or vice versa.
Q: For the extra feature, do I want my php code to kill the program (die...), or do I want to return the error code to my ajax request and do something with it in an onSuccess method?
A: Use the header function to return an error code to the page. It should show up with a red error code in Firebug.
Q: I am trying to add delete icons to each list item. On my first try, I wrote my javascript to include the URL of my icon as part of the list item's .innerHTML. That looked fine on the screen, but of course the URL was being included in the string written to the text file by my PHP whenever .innerHTML was used to read the item.
A: The icon goes inside the list item. Use the DOM; add two children to the li tag: a text node and an img element. Think about what you would want the plain HTML to look like (you can even try coding it up as plain HTML first to check the appearance). Then mimic that set of text/tags in your DOM code.
Q: I am having a problem when I send a Ajax.Request to the PHP page. When I use the "action=set" parameter along with item="xxx\nxxx\n"m, somehow when the item gets to the PHP page, the \n is ignored, and the items in the to-do list becomes one single string. Is it because of the URL-encoding or something?
A: The lack of \n probably means you are not using the right choice between GET and POST.
Q: I'm a little confused, if the file todolist.txt doesn't exist, are we supposed to create it?
A: According to the PHP man pages file_put_contents() will create the file if its not already there.
Q: When I add an item, it appears for a split second before the list becomes empty again. Why?
A: This might be happening if you are wrapping your buttons in a form since it will be treating those buttons as potential submit buttons in Firefox. Don't use a form.
Q: Why doesn't my Sortable work? Why can't I drag all of the items in the list?
A: You may need to set particular ids on your li elements as in the book/slides.
Q: Is it possible to make it so that the "add item to bottom" button is already selected (like in the way if you tabbed to the button) so the user only has to hit enter to add their item?
A: You can add a key event listener to the text box. See the book Chapter 9 on key events for just such an example.
Q: Does the order we save our list in matter? If the user changes the order, then refreshes the page should the server reflect those changes, or revert back to the pre sorted order?
A: Yes, it absolutely does matter, and yes, the server should save it in the rearranged order. (That is kind of the whole point of the assignment.)
Q: The writeup says "You should reject empty strings as to-do items but otherwise can accept any text." Should our todolist.php accept strings consisting of just spaces to add to the list? I'm asking because it's technically not an 'empty string' but HTML doesn't display whitespace very well.
A: Yeah, that's fine; you can accept a spaces-only string.
Q: I'm getting an odd result when I try to make my list sortable. Everything but the last item can be moved around. Any suggestions on what to check?
A: Note that if you make a list Sortable, and then change the list through the DOM (adding an item, etc.), the newly added items won't be movable/draggable/sortable, unless you re-Sortable-ize the list again.
Q: I'm grabbing all the elements that have an li tag and then fading the first one and then deleting it with after that effect finishes with element.remove... Firebug is giving me this error: element.parentNode is undefined it works (fades and deletes) but I always get this error and I have no idea why or how to fix it.
A: some effects (e.g. Shrink) are technically "parallel effects", so to access the modified element, you write effect.effects[0].element rather than just effect.element .
Q: In my html, I create an empty list (ul or ol), and append li tagss to it in the javascript, but the validator doesn't like this. Why not?
A: In valid XHTML all lists have at least one element. Try putting an initial empty hidden element in the list but then deleting it when you insert the actual to-do list contents.
Valid XHTML 1.1 Valid CSS! JavaScript Lint