Created
January 30, 2013 05:29
-
-
Save jmarnold/4670892 to your computer and use it in GitHub Desktop.
Conventional form activation
This file contains hidden or 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($, continuations) { | |
var activateFormsPolicy = { | |
matches: function(continuation) { | |
return continuation.isHtml() && continuation.options.activateForms; | |
}, | |
execute: function (continuation) { | |
var element = continuation.options.element; | |
var content = $(continuation.response.responseText); | |
element.append(content); | |
element.activateValidation(); | |
} | |
}; | |
continuations.applyPolicy(activateFormsPolicy); | |
}(jQuery, jQuery.continuations)); |
This file contains hidden or 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
// somewhere else... | |
$.ajax({ | |
url: 'get/the/form', | |
type: 'GET', | |
acceptType: 'text/html', | |
options: { | |
element: $('#TheContainer'), | |
activateForms: true | |
} | |
}); | |
// Note that the element pattern is particularly useful | |
// You could move the "append" action into a completely seperate policy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment