Custom events in jQuery?

I’m looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like ‘click’ etc, but I’m building a tiny javascript library/plugin to handle some preview functionality. I’ve got a script running to update some text in a dom element … Read more

Difference between document.addEventListener and window.addEventListener?

While using PhoneGap, it has some default JavaScript code that uses document.addEventListener, but I have my own code which uses window.addEventListener: function onBodyLoad(){ document.addEventListener(“deviceready”, onDeviceReady, false); document.addEventListener(“touchmove”, preventBehavior, false); window.addEventListener(‘shake’, shakeEventDidOccur, false); } What is the difference and which is better to use? 4 Answers 4

How to trap “Publish” button to check for meta box validation?

I’m trying to do some form validation on my custom meta box, and I remember somewhere reading about some javascript function to disable/enable the Publish button – except I can’t find it. How do I either a) enable/disable the publish button or, b) when Publish is clicked, trap it and prevent the update and alert … Read more

Custom Post Type Events Archive Grouped By Month

I’m currently trying to get my events listing code to print out headers by Month. So basically this: October event event September event event etc… Right now it just keeps echoing January. I think it might have something to do with the $currentMonth or the strtotime() but I’m not sure what. Any suggestions? I’ve been … Read more

How to stop event bubbling on checkbox click

I have a checkbox that I want to perform some Ajax action on the click event, however the checkbox is also inside a container with it’s own click behaviour that I don’t want to run when the checkbox is clicked. This sample illustrates what I want to do: $(document).ready(function() { $(‘#container’).addClass(‘hidden’); $(‘#header’).click(function() { if ($(‘#container’).hasClass(‘hidden’)) … Read more

1 day after custom date change post status to draft

1 day after koncerter_start_date all posts with custom-post-type koncert have to get the status draft 1 Answer 1 Your question isn’t very clear. Do you mean: 1 day after koncerter_start_date all posts with custom-post-type koncert have to get the status draft? EDIT Code: add_action( ‘wp_loaded’, ‘concert_daily_tasks’ ); function concert_daily_tasks() { $current_url = “https://” . $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’]; if ( $current_url … Read more

Removing event listener which was added with bind

In JavaScript, what is the best way to remove a function added as an event listener using bind()? Example (function(){ // constructor MyClass = function() { this.myButton = document.getElementById(“myButtonID”); this.myButton.addEventListener(“click”, this.clickListener.bind(this)); }; MyClass.prototype.clickListener = function(event) { console.log(this); // must be MyClass }; // public method MyClass.prototype.disableButton = function() { this.myButton.removeEventListener(“click”, ___________); }; })(); The only … Read more

jQuery equivalent of JavaScript’s addEventListener method

I’m trying to find the jQuery equivalent of this JavaScript method call: document.addEventListener(‘click’, select_element, true); I’ve gotten as far as: $(document).click(select_element); but that doesn’t achieve the same result, as the last parameter of the JavaScript method – a boolean that indicates whether the event handler should be executed in the capturing or bubbling phase (per … Read more