jqScribble icon indicating copy to clipboard operation
jqScribble copied to clipboard

Multiple jqScribble and save function don't work properly

Open okwei opened this issue 12 years ago • 2 comments

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();
    });   

okwei avatar Aug 08 '13 17:08 okwei

I'll investigate this and let you know what I find.

jimdoescode avatar Aug 09 '13 19:08 jimdoescode

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');
    }); 
});

jimdoescode avatar Sep 12 '13 15:09 jimdoescode