1

Reduced test case: http://jsfiddle.net/Kerrick/CETWC/

In short, I am creating a jQuery element (such as via var el = $('<h1>Test</h1>');), enabling jQuery UI's draggable functionality (el.draggable()), and appending it to the DOM (such as via $('body').append(el);). Instead of using position: absolute as jQuery UI usually does, it puts position: relative into the style attribute of the element.

Can I prevent this and force jQuery UI to use postion: absolute even when enabled on an element that has yet to be appended to the DOM?

Kerrick
  • 7,420
  • 8
  • 40
  • 45

1 Answers1

0

just change its css to position while appending

$('<h1 class="draggable">Test</h1>')
    .draggable()
    .appendTo('#canvas').css('position','absolute');
$('<h2 class="draggable">Test 2</h2>')
    .draggable()
    .appendTo('#canvas').css('position','absolute');

Is this what you really want?

EDIT:

Though I couldnt figure out the root cause of the problem, these links might help you

Link1 Link2 Link3

Community
  • 1
  • 1
Mandeep Jain
  • 2,304
  • 4
  • 22
  • 38
  • While overriding the `position` property after jQuery UI sets it incorrectly gives me the end goal I'm looking for, I was hoping to find the root of the problem so I didn't need to set the CSS propert via jQuery (or use `!important` in my CSS). – Kerrick Jun 20 '13 at 19:35