jquery - Creating multiple draggable Javascript objects with individual properties -
jquery - Creating multiple draggable Javascript objects with individual properties -
i trying create draggable objects have each have own properties. beginner @ javascript minimal experience, , project involves creating simple circuit simulator.
so far, have been able drag, drop & clone components in dom courtesy of helpful stackoverflow-ers. struggling move on next bit, making each component unique, editable properties such name, type , coordinates, when click on object again, can pull little pop-up menu allows me modify properties of specific object. able offer pointers of how go doing it?
here jsfiddle of have far - http://jsfiddle.net/3lnqocf3/
any help much appreciated!
javascript -
jquery(function() { jquery(".component").draggable({ // utilize helper-clone append 'body' not 'contained' pane helper: function() { homecoming jquery(this).clone().appendto('body').css({ 'zindex': 5 }); }, cursor: 'move', containment: "document" }); jquery('.ui-layout-center').droppable({ activeclass: 'ui-state-hover', accept: '.component', drop: function(e, ui) { if (!ui.draggable.hasclass("dropped")) { var parentoffset = jquery('.ui-layout-center').offset(); var dropped = jquery(ui.draggable).clone().addclass("dropped").draggable(); dropped.css('left', (ui.position.left - parentoffset.left) +'px'); dropped.css('top', (ui.position.top - parentoffset.top) +'px'); jquery(this).append(dropped); } } }); });
javascript jquery html css jquery-ui
Comments
Post a Comment