Solved

Help Get Rid of jQuery Pluggin!

Posted on 2015-01-09
5
110 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
  • 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Put glyphicon in my input button 4 30
HTML Relative path 9 29
Rhino javascript replace special characters 4 21
ASP.NET gridview select textbox on focus 2 15
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
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.
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.

861 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now