Solved

JQuery Mutate Plugin on dynamically created object

Posted on 2013-12-16
3
479 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
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)

856 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