jqScribble
jqScribble copied to clipboard
Multiple jqScribble and save function don't work properly
function saveB() will be called twice in the following code. saveA is not called at all.
<body>
<div id="a"></div>
<div id="b"></div>
<button id="test">test</button>
</body>
<script>
function saveA(){
alert('saveA');
}
function saveB(){
alert('saveB');
}
$('#a').jqScribble({
width: 640,
height: 200,
saveFunction: saveA
});
$('#b').jqScribble({
width: 640,
height: 200,
saveFunction: saveB
});
$('#test').on('click', function(){
$('#a').data('jqScribble').save();
$('#b').data('jqScribble').save();
});
I'll investigate this and let you know what I find.
I apologize for the delay on getting this fixed. One possible work around is to pass your save method in as a closure:
$('#test').on('click', function(){
$('#a').data('jqScribble').save(function()
{
alert('saveA');
});
$('#b').data('jqScribble').save(function()
{
alert('saveB');
});
});