Extjs + jQuery together
How to use Ext.onReady
function and jQuery together ?
I have used ext js for generati开发者_如何学Cng tree and I want to use jQuery for validation of some textfield values.
Or any other way to validate textfield using extjs?
The Ext.onReady
is similar to jQuery's ready
handler, they both fire when DOM becomes ready. This means you can call the jQuery handler normally at a separate line eg:
$(function(){
// your code...
});
Just declare their libraries on top and write their initialilzations on separate lines like below
$(document).ready(function(){ // jquery ready call
// some code here
});
and
Ext.onReady(function(){
/// some code here
});
You may want to see Ext.onReady() vs $(document).ready() for an answer showing how to load both libraries alongside each other.
Ext has built-in validation via textfield configs for some things (e.g. allowBlank: false
) and validator functions for others (all of the VTypes
functions), and also hooks for providing custom validation. Not sure why you'd need to add jQuery just for that, maybe you can be more specific?
But assuming you really do need to use both, you should be able to use either Ext's or jQuery's DOM ready function as your entry point (not both), and then write whatever code you need inside of it assuming both libraries are properly referenced and initialized. Assuming that each library's DOM ready function works as advertised, the DOM should be available when either one is called, which is the only point of using those methods anyway. Since you are using Ext widgets I would probably stick with Ext.onReady
just to be on the safe side, but in theory it really shouldn't matter which function you use.
精彩评论