Solved

JQuery Mutate Plugin on dynamically created object

Posted on 2013-12-16
3
462 Views
Last Modified: 2013-12-24
Hello, I'm using Jquery Mutate Plugin http://www.jqui.net/jquery-projects/jquery-mutate-official/ for changing the size of a div and it was working perfectly, but than I needed this div to be created dinamically through append and then destroy it.

The mutate stop working now and I would like it to work with my dynamically created div as it was working with the static one.


This is the code for the static one:
	$("#user_home_left_column").mutate("height", function(obj, msg){
		
		user_wall_vertical_line_height = $(obj).height() != 0 ? $(obj).height() : user_wall_vertical_line_height;
		$("#user_activity_vertical_line").css("height", (user_wall_vertical_line_height - 155) + "px");
	});

Open in new window



Please help. Thanks.
0
Comment
Question by:ivanblue
  • 2
3 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 39723375
Hi,
is the variable "user_wall_vertical_line_height" somewhere defined outside of your provided script?
Can you post a link to your page or the HTML source where you have the issue?

Thanks.
Rainer
0
 
LVL 1

Accepted Solution

by:
ivanblue earned 0 total points
ID: 39730931
I isolated the problem and now I see it works. Thanks anyways:

<html>
	<head>
		<title>Mutate 1</title>
	</head>

	<body>
		

		<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
		<script src="js/mutate.events.js"></script>
		<script src="js/mutate.min.js"></script>

		<script type="text/javascript">
			$(function(){
				$("body").append(
					"<div id=\"main\" style=\"border:1px solid darkgray;background-color:#efefef;width:500px;position:relative;\">" +
						"<button id=\"btnClick\">Click</button>" +
						"<div id=\"myline\" style=\"position:absolute;top:0;right:5px;width:3px;height:26px;background-color:red;\"></div>" +
					"</div>"
					);

				$("#btnClick").click(function(){
					$("#main").css("height", $("#main").height() + 10);
				});

				$("#main").mutate("height", function (element, info){  
					console.log("main.height: " + $("#main").height());
					$("#myline").css("height", $("#main").height());
				});
			});
		</script>
	</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:ivanblue
ID: 39737665
I find my own answer.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Responsive CSS question 2 42
Safari SVG Image Problem 1 21
CSS Divs in Safari 3 20
Google maps, choose location using pin 10 23
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

743 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

15 Experts available now in Live!

Get 1:1 Help Now