Skip to content

Instantly share code, notes, and snippets.

@townivan
Created July 3, 2014 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save townivan/f8346fcc432db32518a6 to your computer and use it in GitHub Desktop.
Save townivan/f8346fcc432db32518a6 to your computer and use it in GitHub Desktop.
jquerymobile add a control dynamically
<!DOCTYPE html>
<html>
<head>
<title>Load Control Dynamically</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>
<script>
$(document).on( "pageinit", function() {
$( "#addNewButton").on( "click", function() {
$('#Container').append($('<input id="Button1" type="button" value="Custom button" />'));
$('#Container').trigger('create');
});
});
</script>
</head>
<body>
<div id="page1" data-role="page" data-theme="a">
<div data-role="header">
<h1>
Add New button
</h1>
</div>
<div data-role="content" id="content">
<a data-role="button" id="addNewButton">Add New button</a>
<div id="Container" />
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment