Created
January 22, 2014 10:25
-
-
Save matherton/8556512 to your computer and use it in GitHub Desktop.
Example of how to do a simple AJAX injection of a datepicker field on an onClick event. NOTE requires to be run on a server (I use Apache) and the file being injected is stored in a test folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
| <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script> | |
| <link rel="stylesheet" href="../css/ui.css"> | |
| </head> | |
| <body> | |
| <div id="tempload"></div> | |
| <button id="btntest" name="btntest">test</button> | |
| <script type="text/javascript"> | |
| $(document).ready(function(){ | |
| $('#btntest').click(function(){ | |
| $.get("test/test.html",function(data){ | |
| $('#tempload').html(data); | |
| }); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| $(function() { | |
| $( "#datepicker" ).datepicker(); | |
| }); | |
| </script> | |
| <span class="tips" title="Please enter <br/>the required information!"> | |
| <label class="tripDay"> | |
| <input type="text" placeholder="From" id="datepicker"> | |
| </label> | |
| </span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment