April 11, 2012

jquery: vertically expand div when using contained draggable

Question by monsto

I’ve got paragraphs of plain text with specific words hilited. the hilited words are meant to be draggable. when dragging is started, i want the div that hilites the word (#hilite) to expand top and bottom extents (vertically only), in a higher z-order, and allow the word (#word) to be dragged up and down in that space (container: parent). The plans is at some point have it dropped on a droppable within the area.

at this point, my problem is that i expand #hilite with padding… which increases the size of the div without increasing usable space. Would using Resizable be better? or Animate? I’ve seen a number of recommendations for using Resizable, but i thought it was for user resizing not programmatic.

for the droppables, i figure that once the space is created i’ll swap out .css(‘display’, ‘[none|block]’) to show them inside the #hilite div and make them valid targets.

http://jsfiddle.net/monsto/GCsnM/ for what i have atm.

(oh btw, i hate the people came up with jsfiddle. it’s simply too genius.)

Answer by Starx

Your container is a span, which is by default an inline element, it cannot show block properites. You have to tell it behave as block

#hilite { display: inline-block; }

Demo

And the options you gave vertically is false, give Y. Read Here

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!