Created
January 7, 2016 18:42
-
-
Save beau-gosse/e8aae6c83feb351b57b0 to your computer and use it in GitHub Desktop.
[MODX] Change Bible search landing page with JQuery via dropdown menu.
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
// # Change search action, update placeholders and dropdown menu texts | |
var radio = $('input[name="target"]'); | |
radio.change(function(e) { | |
var form = $('#searchform'), | |
target = $("input[name=target]:checked"), | |
targetselect = $('#target_select'), | |
targetlabel = target.data('label'), | |
search = $('#search'), | |
caret = '<span class="caret"></span>', | |
version = $('#version'), | |
site = '[[++site_search_landing]]', | |
bible = '[[++bible_search_landing]]', | |
choice = this.value; | |
if (choice === 'bible') { | |
form.attr('action', bible); | |
search.attr('placeholder', 'Search in ' + targetlabel + ' Ex: Genesis 4:6'); | |
} else { | |
form.attr('action', site); | |
search.attr('placeholder', 'Search in ' + targetlabel); | |
version.prop('disabled', true); | |
} | |
targetselect.html(targetlabel + ' ' + caret); | |
}); | |
// Set default values for the search field placeholder and dropdown menu | |
$('#target_select').html($("input[name=target]:checked").data('label') + ' <span class="caret"></span>'); | |
$("#search").attr('placeholder', 'Search in ' + $("input[name=target]:checked").data('label')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment