i posted here an example of my problem and not my real code (too much code...). The button "copy to clipboard" doesnt copy anything on the first click... only on the second:( Please help
JSP file
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<button onclick="addCopyButton()">Show copy Button</button>
<div id="theCopyButton"></div>
<!-- javascript sources -->
<script src="resources/js/jquery.min.js"></script>
<script src="resources/js/copy.js"></script>
<script src="resources/js/ZeroClipboard.min.js"></script>
</body>
</html>
JS file
$(document).ready(function(){
ZeroClipboard.config( { moviePath: '/goblin/resources/flash/ZeroClipboard.swf' } );
});
function addCopyButton(){
$('#theCopyButton').html('<br/><button type="button" onclick="toClipboard()">Copy to clipboard</button>');
}
function toClipboard(){
$('#theCopyButton').attr('data-clipboard-text', 'dynamic text');
var zeroClipboard = new ZeroClipboard($("#theCopyButton"));
}