Solved

Jquery button help

Posted on 2011-03-02
3
258 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

752 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