Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant initialize after destroy #40

Open
nemanja-ivanis opened this issue Feb 25, 2016 · 0 comments
Open

Cant initialize after destroy #40

nemanja-ivanis opened this issue Feb 25, 2016 · 0 comments

Comments

@nemanja-ivanis
Copy link

After i destroy the instance i cant get it back again,i am destroying it like this...

 jQuery('[data-action="cancel"]').on('click', function(event) {
jQuery('.coords').hide();
econaImage.jrac('destroy');
jQuery('.ui-resizable-handle').remove();

econaToolbar.show();
econaCropperButtons.hide();
 });  

And calling it like this:

jQuery('[data-action="edit"]').on('click', function(event) {

jQuery(econaImage).jrac({
      'crop_width': 250,
      'crop_height': 170,
      'crop_x': 100,
      'crop_y': 100,
      'image_width': 400,
      'viewport_onload': function() {
        var $viewport = this;

        var inputs = jQuery('.coords input:text');

        var events = ['jrac_crop_x','jrac_crop_y','jrac_crop_width','jrac_crop_height','jrac_image_width','jrac_image_height'];
        for (var i = 0; i < events.length; i++) {
          var event_name = events[i];
          // Register an event with an element.


          $viewport.observator.register(event_name, inputs.eq(i));
          // Attach a handler to that event for the element.
          inputs.eq(i).bind(event_name, function(event, $viewport, value) {

                jQuery(this).val(value);
              })
              // Attach a handler for the built-in jQuery change event, handler
              // which read user input and apply it to relevent viewport object.
              .change(event_name, function(event) {


                var event_name = event.data;


                $viewport.$image.scale_proportion_locked = $viewport.$container.parent('.pane').find('.coords input:checkbox').is(':checked');
                $viewport.observator.set_property(event_name,jQuery(this).val());
              });
        }
        $viewport.$container.append('<div>Image natural size: '
            +$viewport.$image.originalWidth+' x '
            +$viewport.$image.originalHeight+'</div>')
      }
    })
    // React on all viewport events.
    .bind('jrac_events', function(event, $viewport) {
      var inputs = jQuery(this).parents('.pane').find('.coords input');
      inputs.css('background-color',($viewport.observator.crop_consistent())?'chartreuse':'salmon');
    });

jQuery('.coords').show();
econaToolbar.hide();
econaMoveButton.removeClass('active');
econaCropButton.addClass('active');
econaCropperButtons.show();



  });

Is there a way to resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant