Solved

Jquery button help

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
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…

809 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