Last active
December 15, 2015 12:09
-
-
Save Fab1en/5258377 to your computer and use it in GitHub Desktop.
Three means to display help content.
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
.hidden{ display: none; } |
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
<div id="page"> | |
<div id="display"> | |
<h1>Info</h1> | |
<p>Some text</p> | |
</div> | |
<button id="help1">Show help (embedded)</button> | |
<button id="help2">Show help (json)</button> | |
<button id="help3">Show help (html ajax)</button> | |
<div class="hidden" id="help-content"> | |
<h1>Help</h1> | |
<p>Here is the embedded version help content</p> | |
<a href="http://www.dailymotion.com/video/x309hk_the-beatles-help_music">Help link</a> | |
</div> | |
</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
jQuery(function($){ | |
$('#help1').click(function(){ | |
// get content from local DOM | |
$('#display').html($('#help-content').html()); | |
}); | |
$('#help2').click(function(){ | |
// get content from remote JSON file | |
$.get('/gh/gist/response.json/5258377', function(data){ | |
$('#display').html(data.help); | |
}, 'json'); | |
}); | |
$('#help3').click(function(){ | |
// get content from remote HTML file + select by id | |
$('#display').load('/gh/gist/response.html/5258377 #help-content'); | |
}); | |
}); |
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
name: Three means to display help content |
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
<div id="page"> | |
<div id="help-content"> | |
<h1>Help</h1> | |
<p>Here is the ajax html version help content</p> | |
<a href="http://www.dailymotion.com/video/x309hk_the-beatles-help_music">Help link</a> | |
</div> | |
</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
{"help":"<h1>Help<\/h1><p>Here is the JSON version of the help content<\/p><a href=\"http:\/\/www.dailymotion.com\/video\/x309hk_the-beatles-help_music\">Help link<\/a>"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment