1

I came across an issue when applying a .draggable() while also using a function that will rotate the div when user clicks it:

//functions for roating text contianer jQuery.fn.rotate = function(degrees) { $(this).css({'-webkit-transform' : 'rotate('+ degrees +'deg)', '-moz-transform' : 'rotate('+ degrees +'deg)', '-ms-transform' : 'rotate('+ degrees +'deg)', 'transform' : 'rotate('+ degrees +'deg)'}); }; $('#draggable').click(function() { rotation += 5; $(this).rotate(rotation); }); 

the #draggable is appeneded to a container after a certain function is executed, using Jquery to append(....) the div into the container; I apply the .draggable() function to it.

$(".customize-Container").append("<div id='draggable'><span id='"+current+"'></span></div>"); .... $( "#draggable" ).draggable(); 

I am not sure if this is because it does not exist and than when JQuery appends it, it still stays hidden or what.

I have tried this function on other divs that are populated into the webpage and it works wonderful. Let me know your ideas.

David

3
  • Depends on the jQuery v. you use, but thankfully you don't need all those browser-specifics, just transform (the last one) Commented Jul 9, 2013 at 15:29
  • @RokoC.Bulijan what do you mean? Commented Jul 9, 2013 at 15:31
  • I mean the -browserVendor-specific attributes Commented Jul 9, 2013 at 15:35

1 Answer 1

3

Hope this helps

jQuery.fn.rotate = function(degrees) { $(this).css({ transform : 'rotate('+ degrees +'deg)' }); }; var rotation = 0; $('.customize-Container').on('click', '#draggable', function() { rotation += 5; $(this).rotate(rotation); }); 
Sign up to request clarification or add additional context in comments.

1 Comment

@DavidBiga don't be afraid, if you use an up-to-date jQuery version this is all you need

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.