Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This snippet is intended to fix themes that override form
- submissions and include placeholder text in the data submitted.
- Add this to your theme's functions.php file.
- */
- function hide_tribe_placeholders($before) {
- $before .= '
- <script type="text/javascript">
- jQuery(document).ajaxStart(function(){
- // Hides placeholder text for each element to prevent its submission
- jQuery(".tribe-bar-filters-inner input").each(function(){
- _self = jQuery(this);
- // Check to see if the value = placeholder value, clear it if so
- // Some themes set the value from the placeholder, causing erroneous data to submit
- if(_self.val() == _self.attr("placeholder"))
- _self.val("");
- // Store placeholder text in data, then clear placeholder
- jQuery.data(this, "tribe-placeholder", _self.attr("placeholder"));
- _self.attr("placeholder", "");
- });
- }).ajaxComplete(function(){
- // Shows placeholder text now that submission is complete
- jQuery(".tribe-bar-filters-inner input").each(function(){
- ptext = jQuery.data(this, "tribe-placeholder");
- if(typeof ptext === "string" && ptext != "")
- jQuery(this).attr("placeholder", ptext);
- });
- });
- </script>';
- return $before;
- }
- add_filter( 'tribe_events_before_html', 'hide_tribe_placeholders');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement