Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help Get Rid of jQuery Pluggin!

Posted on 2015-01-09
5
Medium Priority
?
124 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

927 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