14

所以我使用这个简洁的 jquery 插件http://odyniec.net/projects/imgareaselect/ 它工作正常,但我用 jquery ui 回调函数(对话框)触发它,我需要在对话框关闭后删除选择。

function initialize_selection() {
$('#image_area').imgAreaSelect({ x1: 10, y1: 10, x2: $('#image_area').width()-10, y2: $('#image_area').height()-10 , fadeSpeed: 400, handles: true});
}

$(function() {
$('#image_edit').click(function(){
    $('#edit_image_dialog').load('actions.php?action=edit_temp_image', function(){
            $('#edit_image_dialog').dialog({
                modal: true,
                resizable: false,
                width: 480,
                    buttons: {
            Ok: function() {
                        //foo_bar                                                                        
            },
                        Cancel: function() {
                        //foo_bar
            }
                    },
                    beforeclose: function(){
                    //What should i put here ???
                    ;}
            });
    initialize_selection();
        });
    });
});

我真的很感激一些提示,因为我是 jquery 的新手,我自己无法解决这个问题。

谢谢

4

7 回答 7

22

http://odyniec.net/projects/imgareaselect/usage.html

$('#image_area').imgAreaSelect({remove:true});

应该可以,但不确定

于 2010-03-05T13:49:43.577 回答
6

我发现删除选择处理区域的唯一方法如下:

"Close": function() { 
  $(".imgareaselect-selection").parent().remove();
  $(".imgareaselect-outer").remove();
  $(this).dialog("close"); 
},

以下对我不起作用(在 Wordpress 3.0.5 中的 jquery 和 jqueryui 元素中)

$(selector).imgAreaSelect( {remove: true} );
于 2011-02-20T23:42:39.380 回答
5

这对我有用:

var $ias = $('#imageArea').imgAreaSelect({
    instance: true
});

$('#clearBtn2').click(function() {
    $ias.cancelSelection();
});
于 2011-10-14T20:19:46.370 回答
3

According to the documentation for the options at HomeimgAreaSelect Documentation

$('#image_area').imgAreaSelect( {remove: true} );

will do the trick

于 2010-03-05T13:38:44.483 回答
1

根据文档: http: //odyniec.net/projects/imgareaselect/usage.html

{remove: true} 实际上会完全删除 imgAreaSelect-y-ness。如果您想要做的只是框和灰色区域,(但允许用户稍后拖动新框)您想要 {hide: true}。

$('#image_area').imgAreaSelect( {hide: true} );
于 2012-10-19T19:00:03.407 回答
1
$('#image_area').imgAreaSelect({remove:true}); //For hiding the imagearea
$('#image_area').imgAreaSelect({remove:false}); //For resetting the imagearea

第一条语句隐藏 imgareaselect,第二条语句有助于在下次加载模式时重新加载裁剪功能。

我在从模态返回主窗口时使用了这两个语句,这样下次加载裁剪功能就没有问题了。

于 2014-08-22T02:14:09.240 回答
0

是的,它确实有效,但在 -->$('#image_area').imgAreaSelect({remove:true}); 它不能用于标记其他照片

于 2010-03-31T09:14:54.960 回答