Created
September 22, 2014 17:24
-
-
Save aaronmccall/24e44b7096e4c87c6d08 to your computer and use it in GitHub Desktop.
init jquery ui widget on first click
This file contains 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
<input class="addDatepicker" name="date"> |
This file contains 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
<span class="dialogControl" id="question" data-dialogTarget="#answer">?</span> | |
<div class="dialogContent" id="answer"> | |
<!-- dialog content here --> | |
</div> |
This file contains 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
$(document).ready(function (){ | |
$('.addDatepicker').on('click', function () { | |
// If we're not actually a datepicker yet, make us one. | |
if ($(this).not(':data(datepicker)')) { | |
$(this).datepicker({ | |
// my datepicker options | |
}); | |
} | |
}); | |
$('.dialogControl').on('click', function () { | |
var $target = $($(this).data('dialogTarget')); | |
if ($target.length) { | |
if ($target.not(':data(dialog)'))) { | |
$target.dialog({ | |
// my dialog options | |
}); | |
} | |
$target.dialog("open"); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment