mathiasbynens / jquery-placeholder

A jQuery plugin that enables HTML5 placeholder behavior for browsers that aren’t trying hard enough yet
https://mths.be/placeholder
MIT License
3.98k stars 1.34k forks source link

Update jquery.placeholder.js #201

Closed rzcrjz closed 9 years ago

rzcrjz commented 10 years ago

The jquery placeholder plugin takes care that elements that don't support a placeholder are assigned to the 'value' attribute. But on the moment of the submit they must be detached from what is already in the code. Only problem with the existing code was that the selector and event arguments are in the wrong order which caused the code not to execute.

amerikan commented 9 years ago

Thanks for the PR.

Current plugin code:

//                Selector | event
$(document).delegate('form', 'submit.placeholder', function() {

Per jQuery docs here:

// jQuery 1.4.3+  delegate()
$( elements ).delegate( selector, events, data, handler );
// jQuery 1.7+   on()
$( elements ).on( events, selector, data, handler );

So as you can see, the way it is now it is fine...

Now, jquery-placeholder plugin officially supports jQuery 1.6+. Your proposed pull request would fix it if it were using .on(), but .on() only works with 1.7+. Can you try to find a solution and amend your code to support both cases?

amerikan commented 9 years ago

Actually, after further thinking about it this is not really a fix. Since you reverse the order of the delegate args you basically just removed the submit event.