javascript - How can I make a sortable, changeable, addable, removable web-page element? -
i'm creating web-app interface allow users construct sentences clicking on words/phrases. each word of phrase contained in own page element, eg. <div>
. div class need allow:
- dragging different order relative other divs/words (ie. sorting)
- an x (only visible when hovering over) in top right corner of box remove upon clicking
- changing of font/text upon click actions
- be inserted page when user wishes add word
for instance, imagine page (quote marks denote element):
"hi, name is" [textbox] "i work at..." "and born in" [combobox]
the phrase in italics 'inactive' , not part of sentence, if user clicked change "i work at" [textbox] , new div added eg. "and at..." allow further expansion. phrases in bold have close button /clickable action rid of them or make them inactive again. draggable change order. can see need dynamically insert new textboxes , comboboxes accommodate more phrases requiring input.
could give me brief run down on steps need take? i've seen sortable list elements in jquery eg. http://jsfiddle.net/ctrlfrk/a4k4t/ start. need spruce basic javascript , css? or need use server-side scripting dynamically add more page content?
to summarize, need div change font/text upon clicking, have hover-over close button, remove , inserted upon simple click events, , sortable dragging. need comboboxes/textboxes added/removed in parallel.
any tips appreciated.
you don't need server new content unless stored or generated there.
not having done exact thing before don't see grand scheme implement, add features incrementally until need go. may have refactor things bit along way, don't have tell that. ;)
one thing have when add or delete elements rebind jquery functions, won't enough call them when document loads. put them in function , call whenever add or remove element.
regarding description of ui behavior, inactive elements can dragged , can made active clicking on them. can (just see if thing has been dragged or not on mouseup know whether drag or click) might not best ui design choice, imo. wouldn't worst thing in world, find little frustrating when wrong thing happens when try something. of course, implementing , seeing best.
Comments
Post a Comment