Solved

Help Get Rid of jQuery Pluggin!

Posted on 2015-01-09
5
118 Views
Last Modified: 2015-01-15
I'm using this pluggin:  imgAreaSelect

The plugin works fine.  However, I can't get the selection to go away when the plugin is removed from the page.  It is put in the page via ajax, and the page content is updated via ajax too.  But when the ajax fires and changes the content, the image area selection still shows on the page!

I tried using remove() to totally remove the div with the javascript code and all the related stuff, but that doesn't work.

Want to see what I mean?  It will probably help to see whats up.
Go to this page:  profile page
Hover your mouse over the profile picture and click the change profile pic button.
Upload a picture
Now you'll be on the screen with the plugin.  Now to see the error click the "status" tab which is above the image you uploaded.

So you see my problem.  Any clever ideas to help?

Thanks experts!
0
Comment
Question by:Elxn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 40540400
Here's an example of how to capture the coordinates of the selection into html inputs and then remove the plugin afterward.
<script type="text/javascript">
$(document).ready(function () {
	var ias = $('#ias').imgAreaSelect({ instance: true });
	ias.setOptions({ x1: 60, y1: 14, x2: 240, y2: 194, aspectRatio: '1:1', handles: true, 
                 onSelectEnd: function (img, selection) {
			$('input[name="x1"]').val(selection.x1);
			$('input[name="y1"]').val(selection.y1);
			$('input[name="x2"]').val(selection.x2);
			$('input[name="y2"]').val(selection.y2); 
			ias.remove();
		} 
	});
});
</script>

Open in new window

0
 
LVL 2

Author Comment

by:Elxn
ID: 40542285
Hmm..  I'll give it a shot.  But I thought of this already and didn't do it cause i figured the plugin would go away after the user moved the selection area once.  So they'd then only get one modification of the crop area; that won't do.  

But maybe this means it will be removed when they click the button to save their cropped picture.

Thanks, I'll try it out and see what happens!
0
 
LVL 2

Author Comment

by:Elxn
ID: 40542446
Okay I tried it.

It still persisted even doing it that way so it didn't solve the problem.  Also the plugin didn't work anymore when i did it this way; it just showed the initial selection area but you couldn't move it around or change the dimensions of the selection.

Oh, i should say, if i put it in a document dot ready function it doesn't work at all; so i had to take out that encapsulating function to even get the selection area to show.

Any other ideas?
0
 
LVL 2

Accepted Solution

by:
Elxn earned 0 total points
ID: 40542512
Okay I got it figured out.

I just had to use the hide setting as said by the documentation.

Just used this code:

$('#ias').imgAreaSelect({hide:true});

Should have seen this earlier!!!
0
 
LVL 2

Author Closing Comment

by:Elxn
ID: 40550857
I figured it out myself.  Should have seen this earlier.  If i could reduce the points to 0 I would but I don't know if you can even do that.

So I'll let you moderators see what you think the points should be!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS style formatting? 2 33
Pass SQL to JSON. Page is in classic ASP and using Jquery 4 37
how can i break an array into a couple 5 24
Print a <div></div> only 5 36
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to dynamically set the form action using jQuery.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question