Solved

Help Get Rid of jQuery Pluggin!

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

630 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