3
I’m trying to make a little project just to learn more about HTML5, CSS3 and Javascript. In this project I have a div
which is kind of a panel
and another div
that would be a square that I would put inside that panel
. I’m using the drag and drop to be able to drag these elements around the screen.
My question is: how could I do for when I put the div
within the panel
she bind herself to it and when I try to drag the panel
, I drag him and the div
? And also this panel automatically adjust to the size of the div
?
This happens on the website of scrumwise...
The code I already have is this one:
panel
<div class="panel panel-success" id="panel">
<div class="panel-heading">
<h3 class="panel-title">Qualquer texto</h3>
</div>
<div class="panel-body">
</div>
</div>
Div
<div style="width:100px; height: 100px; background-color: black;" id="div">
</div>
The javascript
<script type="text/javascript">
$(function () {
$("#panel").draggable();
$("#div").draggable();
});
</script>
Another thing, I’m using the bootstrap also!
Very good! There was something else I wanted to ask you... In the style of what happens on the website of scrumwise, could I create a div, in the same style that did, and save the state of the div? Because the way you see it, if I give you an F5, the Divs are unbound...
– Érik Thiago
@Thank you. Well, that would be something more complicated.. since it would have a backend, or at least a rescue in Storage. I only did the front-end for what was in the question. If you want something more "sophisticated" would be the case to ask another related question.
– Samir Braga
So I’ll do it! Thanks for the tip!
– Érik Thiago
@Érikthiago, I’m preparing a very simple model with
localStorage
, only to illustrate, when finished, post..– Samir Braga
OK! Now created the question.
– Érik Thiago
@Érikthiago, very good.. now just wait... :) But there would be something else that would doubt about the front-end?
– Samir Braga
Ah, I have doubts about the bootstrap grids system. Because I wanted to put kind of next to each other and everything... But according to time I’m learning more! And dear, thank you so much for the willingness and for helping to solve!
– Érik Thiago
@Érikthiago, nothing expensive. I’m glad I helped :) . But if the answer fits perfectly, you can "accept" it, so you will know that the problem, at least of this question, has been solved.
– Samir Braga
Ah had forgotten! Only if it is now!
– Érik Thiago