admin管理员组文章数量:1415100
I use query plugin named fooTable for my data table (/)
Below is my code to initialize my datatable...
jQuery(function($){
$('.table').footable({
"paging": { "size": 15 },
// "toggleColumn": "last",
"showToggle": false,
"columns": $.get('/footable/js/columns.json'),
"rows": $.get('/footable/js/rows.json')
})
})
My question is how to do something after it finished initialize?
I try
jQuery(function($){
$('.table').footable({
"paging": { "size": 15 },
// "toggleColumn": "last",
"showToggle": false,
"columns": $.get('/footable/js/columns.json'),
"rows": $.get('/footable/js/rows.json')
})
.done(function(){
alert('do something');
})
})
But it was not working.
I use query plugin named fooTable for my data table (http://fooplugins.github.io/FooTable/)
Below is my code to initialize my datatable...
jQuery(function($){
$('.table').footable({
"paging": { "size": 15 },
// "toggleColumn": "last",
"showToggle": false,
"columns": $.get('/footable/js/columns.json'),
"rows": $.get('/footable/js/rows.json')
})
})
My question is how to do something after it finished initialize?
I try
jQuery(function($){
$('.table').footable({
"paging": { "size": 15 },
// "toggleColumn": "last",
"showToggle": false,
"columns": $.get('/footable/js/columns.json'),
"rows": $.get('/footable/js/rows.json')
})
.done(function(){
alert('do something');
})
})
But it was not working.
Share Improve this question edited Oct 2, 2016 at 10:24 Ehsan Sajjad 62.6k16 gold badges112 silver badges170 bronze badges asked Oct 2, 2016 at 10:17 DreamsDreams 8,51611 gold badges50 silver badges73 bronze badges4 Answers
Reset to default 3You should use the postinit.ft.table
event along with the on
option as mentioned by @Roamer-1888. (You can click on any option to see a small example of how to use it.)
jQuery(function($) {
$('.table').footable({
// your other options
'on': {
'postinit.ft.table': function(e, ft) {
/*
* e: The jQuery.Event object for the event.
* ft: The instance of the plugin raising the event.
*/
// all initialized - do stuff here
}
}
});
});
Alternatively the second argument to the plugin constructor is a ready callback so you can just provide a function to execute once everything is done.
jQuery(function($) {
$('.table').footable({
// your options
}, function(ft){
/*
* ft: The instance of the plugin raising the event.
*/
// all initialized - do stuff
});
});
use postinit.ft.table
event. See http://fooplugins.github.io/FooTable/docs/jsdocs/FooTable.html#.event:Table%2522postinit.ft.table%2522
The postinit.ft.table event is raised after any ponents are initialized but before the table is drawn for the first time. Calling preventDefault on this event will disable the initial drawing of the table.
Also, postdraw.ft.table
is what you may want.
About how to use it
I am not very familiar to it. So give it a try. If it doesn't work tell me.
.when('postinit.ft.table', function(e, ft){
//ok
})
The FooTable documentation is difficult to follow as it's not over-endowed with examples.
I think @turle's suggestion to use the "postinit.ft.table" event is a good one, however I can't see that .when('postinit.ft.table', function(e, ft){ /* do something */ })
is the right syntax.
As far as I can gather from here, event handlers are attached using the "on" option.
Try :
jQuery(function($) {
$('.table').footable({
'paging': { 'size': 15 },
// "toggleColumn': "last",
'showToggle': false,
'columns': $.get('/footable/js/columns.json'),
'rows': $.get('/footable/js/rows.json'),
'on': {
'postinit.ft.table': function(e, ft) {
/*
* e: The jQuery.Event object for the event.
* ft: The instance of the plugin raising the event.
*/
// all initialized - do stuff here
}
}
});
});
Just try 'ready.ft.table'
Something like
jQuery(function($){
$('.table').footable({
"on": {
"ready.ft.table": function(e, ft){
// bind to the plugin initialize event to do something
}
}
});
});
本文标签: javascriptHow do I continue do things after finish footable initializeStack Overflow
版权声明:本文标题:javascript - How do I continue do things after finish footable initialize? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745153533a2645029.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论