Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE problems with JCrop

I am using jcrop with my aspx page:

<script type="text/javascript" src="../../Scripts/js/jquery.Jcrop.min.js"></script>
<link rel="Stylesheet" href="../../Scripts/css/jquery.Jcrop.min.css" />

Here is my JCrop declaration:

 <script type="text/javascript">
    $(document).ready(function () {
        $('#' + options.ImageID).Jcrop({
            onChange: function (coords) {
                $('#' + options.HiddenID).val(coords.x + ',' + coords.y + ',' + coords.w + ',' + coords.h);
            },
            aspectRatio: 1
        });
    });
</script>

Here is my .NET image:

<asp:Image runat="server" ID="PhotoPreviewImage" />

The options variable is an object created in the code behind to pass the ClientID of PhotoPreviewImage to the JS.

This works great in Chrome, it doesn't work in IE9 (I don't even get the crosshairs).

I am using jquery.Jcrop.min.js v0.9.10 (build:20120429) and jQuery v1.7.1 jquery.com

How can I make this work in IE?

like image 871
Liath Avatar asked May 15 '26 19:05

Liath


1 Answers

I ended up having to detect IE and use one of two formats to initialize:

        var is_msie = /msie/.test(navigator.userAgent.toLowerCase());
        var jcrop_obj;

        if (is_msie) {
            jcrop_obj = jQuery.Jcrop('#img', {
                onSelect: jcrop_onEndCrop,
                minSize: [ 20, 20 ],
                setSelect: [ x, y, x2, y2 ],
                allowSelect: false
            });
        }
        else {
            jQuery('#img').Jcrop({
                onSelect: jcrop_onEndCrop,
                minSize: [ 20, 20 ],
                setSelect: [ x, y, x2, y2 ],
                allowSelect: false
            },function(){jcrop_obj = this;});
        }
like image 135
Jeff Widmer Avatar answered May 17 '26 07:05

Jeff Widmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!