Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I improve this jQuery Gmail-like interface?
    primarykey
    data
    text
    <p><strong>EDIT 3:</strong> I've gotten this working by ignoring the advice given below and listening on the window, but only when an <code>input</code>, <code>text</code> field, or <code>textarea</code> is not focused. I'm not sure if this is the best way to be handling this issue, though.</p> <p><a href="http://jsfiddle.net/gXPES/5/" rel="nofollow">http://jsfiddle.net/gXPES/5/</a></p> <hr> <p><strong>EDIT 2:</strong> I've tried addressing the <code>keydown</code> issue by applying <code>focus</code> and <code>blur</code> handlers to <code>input</code>s. Then I only listen for events when <code>var focus_on_input == true</code>. But it seems that not all is well. This is preventing some behaviors, but causing other, more bizarre behavior. For example, when I <kbd>tab</kbd> out of the input field, pressing <kbd>J</kbd> and <kbd>K</kbd> will jump to the top or bottom of the list. If I <code>click</code> elsewhere and shift focus, this issue is fixed. Any thoughts?</p> <hr> <p><strong>EDIT:</strong> Thanks to answerer help, I've limited the selectors when listening for <code>keydown</code> so that I can still type characters elsewhere, but I'm running into a new issue. When I press <kbd>J</kbd> or <kbd>K</kbd> the arrow nav jumps to the top or bottom of the task list. And when I press <kbd>C</kbd> or <kbd>#</kbd> it will notify me that no tasks are selected. <kbd>X</kbd> functions as it should and does not select a task.</p> <hr> <p>Hosting <a href="http://jsfiddle.net/gXPES/" rel="nofollow">this code on JSFiddle</a> since there's no possible way to comment on it in its entirety here. I've posted all my JS, CSS, and HTML used for the interface itself.</p> <p>I'm designing a Gmail-inspired UI for task management using jQuery on the front-end (and PHP on the back-end, though it's largely irrelevant to this).</p> <p>I'm still relatively new to jQuery development and so I realize <strong>I'm doing a number of things wrong</strong>. Until now, I simply haven't known <strong>what exactly</strong> I'm doing wrong nor <strong>how to fix it</strong>. I was hoping some more learned souls might help me (and others, hopefully) figure out how to refactor jQuery code for a larger-sized application.</p> <p>To start, here are a number of things I would like to know how to do better:</p> <ol> <li><p>Call this code only when the task interface is active.</p></li> <li><p>Improve the listening for the <code>keydown</code> event. Currently I listen for <kbd>J</kbd>, <kbd>K</kbd>, <kbd>X</kbd>, <kbd>Shift+3</kbd>, and <kbd>C</kbd>. I will also be listening on <kbd>E</kbd> for task editing, but haven't yet implemented edits. <strong>The problem with the listeners</strong> is related to my first concern, which <strong>is that they are always on</strong>. This means that pressing <kbd>J</kbd> while in a <code>&lt;textarea&gt;</code>, for example, will not result in the default behavior.</p></li> <li><p>Use less HTML in my code.</p></li> <li><p>Make my code generally more DRY.</p></li> </ol> <p>Any thoughts, no matter how critical, are more than welcome. Again, I realize I am not following best practices here, but that's because I'm dumb to them. I want to learn, and hope to use this opportunity to do so.</p> <p>Cheers!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload