That solved it, Tnx!
Ok so now I got this very simple real jQuery example that works
http://jsfiddle.net/tovic/mkUJf/I now ported it to haxe.
new JQuery(this) doesnt seem to work because of what 'this' is in javascript and 'this' is in haxe.
So I used
new JQuery(Lib.nativeThis) instead.
But it still wont work.
Does JQuery in haxe has some helpercode this problem?
This is my haxe code
package;
import js.Lib;
import js.jquery.*;
new JQuery(function() {
new JQuery('body').on('mousedown', 'div', function() {
new JQuery(
Lib.nativeThis).addClass('draggable').parents().on('mousemove', function(e) {
new JQuery('.draggable').offset({
top: e.pageY - new JQuery('.draggable').outerHeight() / 2,
left: e.pageX - new JQuery('.draggable').outerWidth() / 2
}).on('mouseup', function() {
new JQuery(
Lib.nativeThis).removeClass('draggable');
});
});
}).on('mouseup', function() {
new JQuery('.draggable').removeClass('draggable');
});
});
}
}
and this as html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
padding:50px;
}
div {
cursor:move;
width:70px;
height:70px;
background-color:black;
border:1px solid black;
margin:2px;
float:left;
}
.draggable {
background-color:yellow;
}
</style>
<title>test</title>
<meta name="description" content="" />
</head>
<body>
<script src="test.js"></script>
<div class=""></div>
<div class=""></div>
<div class=""></div>
<div class=""></div>
<div class=""></div>
<div class=""></div>
</body>
</html>
Op dinsdag 10 januari 2017 17:17:38 UTC+1 schreef Andy Li: