jQuery Snippet Not Working on WordPress Site [closed]
jQuery Snippet Not Working on WordPress Site [closed]
jQuery Snippet Not Working on WordPress Site [closed]
Custom WP rest api endpoint only working on non https?
I finally find out the problem. The problem is when I load wordpress page a builtin ajax call is started. and this part of my code: jQuery(document).ajaxStart(function() { jQuery( “#step-general” ).hide(); jQuery( “.pelak-loader” ).show(); }).ajaxSuccess(function() { jQuery( “.pelak-loader” ).hide(); }); is used on loading page. I use if conditional in ajaxStart to limit its border!
After more reading and testing, i’ve realised that i misunderstood how AJAX works, therefore it was never gonna work the way i thought it would. For those who come across this, i hope this will help. In shortcode function i generated the api url with params specific to the page where shortcode is called. eg … Read more
For anyone interested, I was able to resolve it like so: function form_checkboxes_validation(){ ?> <script type=”text/javascript”> (function($){ $(“#send-request”).click(function(){ if(! $(‘input[name=”form_fields[suite][]”]’).is(‘:checked’)) { alert(“Please select at least one suite!”); return false; } }); })(jQuery); </script> <?php } add_action(‘wp_footer’, ‘form_checkboxes_validation’);
Since you already loading JQuery, add the following $(‘document’): (function($) { $(window).load(function() { //lets wait for all to be loaded alert(“Accordion script loaded”); var acc = document.getElementsByClassName(“accordion”); var i; for (i = 0; i < acc.length; i++) { acc[i].onclick = function() { this.classList.toggle(“active”); var panel = this.nextElementSibling; if (panel.style.maxHeight){ panel.style.maxHeight = null; } else { … Read more
Error – Uncaught TypeError: e.dispatchEvent is not a function
as example of js code that will run on every new post page function admin_footer_se_119285(){ ?> jQuery(window).ready(function(){ if (jQuery(‘#metabox-id-div’).length == 1){ // put your code } }) <?php } ?> Take a look to usefull reference to admin_footer-(plugin_page) action hook
I figure it out. This may be a bad solution but atleast it works $(‘.inside’).bind(‘DOMNodeInserted DOMNodeDeleted’, function(event) { //WRITE WHAT YOU NEED TO DO} Inside a file abhiScript.js (could be any filename 🙂 ) and wp_enqueue_script( ‘SimpleScript’, get_template_directory_uri() . ‘/assets/js/abiScript.js’,array(‘jquery’)); in function.php
Use admin_enqueue_scripts action instead of admin_head. Then see network tab in dev tools that datepicker scripts are included. You need the include the jQuery UI CSS also, it is not included in WP core.