Reputation: 1001
I'm not sure about what title I need to use or what I need to call what I'm gonna do, here is the problem
there is a code in sortable.js
var sortableStuff;
sortableStuff = {
sortableList = $('#mySortable');
init: function(){
sortableList.sortable({
start: function(){
lot of codes here...
},
stop: function() {
another codes here..
}
});
}
}
I want to extend the start and stop function from another another file for example mysortable.js
but still run the start and stop callback from the one above.
sortableStuff.sortableList.sortable({
start: function(){
run the code from the start before..
run my new code
}
})
I'm not a javascript expert, and don't know what to call what I'm trying to do here, please help me.
Upvotes: 0
Views: 144
Reputation: 664589
You've got a syntax error in your first script, mixing object literals with variable assignments. It should be
var sortableStuff = {
sortableList: $('#mySortable'),
// ^ ^
init: function() {
this.sortableList.sortable({
// ^^^^^ use as a property
start: function(){
// lot of codes here...
},
stop: function() {
// another codes here..
}
});
}
};
Now you can access sortableStuff.sortableList
from outside, and depending on how your sortable
plugin works be able to extend/add/overwrite callbacks.
Upvotes: 1