Solved

Jquery button help

Posted on 2011-03-02
3
260 Views
Last Modified: 2012-06-27
Hi

Im trying to create dynamic table which will insert row to end of the table and row contains a jquery button

row adding works fine. but button not working

i guess its because im adding button after document ready.

how to fix this problem?
0
Comment
Question by:3xtr3m3d
[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
  • 2
3 Comments
 
LVL 2

Expert Comment

by:mhmr
ID: 35020644
Hello
you can try like this :

	
<div id="mydiv">
</div>
<script> 
$("#mydiv").append('<table><tr><td>I Am The 1st</td></tr><tr><td><button id="btn">am a button</button></td></tr></table>');
$("#btn").live ( "click" , function () { alert('you pressed me??'); } );
</script>

Open in new window

0
 
LVL 3

Author Comment

by:3xtr3m3d
ID: 35034303
Hi

Thanks for reply and buttons now working but created  button is just a button and is it possible to change created button back to a jquery ui button?

current code is

$(document).ready(function() {

	$( '.Eb1' ).button({
		icons: {
			primary: "ui-icon-arrowthick-1-w"
		},
		text: false
	})
	.click(function() {
		$("#mydiv").append('<table><tr><td>I Am The 1st</td></tr><tr><td><button id="btn">am a button</button></td></tr></table>');
	});
	
					
	$("#btn").live ( "click" , function () { 
		alert('you pressed me??');
	});

});

Open in new window


<div id="mydiv"></div>
<button class="Eb1">add</button>

Open in new window

0
 
LVL 2

Accepted Solution

by:
mhmr earned 500 total points
ID: 35037699
yes you can do it like this
	$(document).ready(function() { 
	$( '.Eb1' ).button({  
		icons: {
			primary: "ui-icon-arrowthick-1-w"
		},
		text: false
	})
	.click(function() {
		$("#mydiv").append('<table><tr><td>I Am The 1st</td></tr><tr><td><button id="btn">i am a button</button></td></tr></table>');
		$("#btn").button({  
			icons: {
				primary: "ui-icon-arrowthick-1-w"
			},
			text: false
		}
		).click(function () {
			alert('you pressed me??');
		});
	});					

	});

Open in new window

<div id="mydiv"></div>
<button class="Eb1">add</button>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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…
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