Created
May 4, 2014 09:22
-
-
Save guoxiangke/0dffa7722a67f052c7ce to your computer and use it in GitHub Desktop.
ajax node form submit ,check before submit
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
(function ($) { | |
Drupal.behaviors.confirm = { | |
attach: function(context, settings) { | |
var events = $('.node-weibo-form input[name=op]').data('events'); // Get the jQuery events. | |
$('.node-weibo-form input[name=op]').unbind('mousedown'); // Remove the click events. | |
var name = $('.node-weibo-form input[name=title]').val(); | |
$('.node-weibo-form input[name=op]').mousedown(function () { | |
// var events = $('.node-weibo-form input[name=op]').clone(true).data('events');// Get the jQuery events. | |
// $('.node-weibo-form input[name=op]').unbind('mousedown'); // Remove the click events. | |
var name = $('.node-weibo-form input[name=title]').val(); | |
if (name != '姓名') { | |
$.each(events.click, function() { | |
//Uncaught TypeError: Cannot read property 'click' of undefined?????? | |
this.handler(); // Invoke the mousedown handlers that was removed. | |
}); | |
}else{ | |
alert('必须要填写姓名!'); | |
$('.node-weibo-form input[name=title]').focus(); | |
} | |
// Prevent default action. | |
return false; | |
}); | |
} | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment