jQuery関数でビューモデル関数を呼び出す方法は? Javascript関数からviewmodel関数の関数を呼び出したいだけです。
function ContactsViewModel(data) {
var self = this;
// Editable data
self.Contacts = ko.observableArray(JSON.parse(data));
self.limit = ko.observable(20);
self.changeNumber = function(item){
self.limit(self.limit()+20);
self.Contacts.push(item);
}
self.myPostProcessingLogic = function(elements) {
if ($('#KnockOutContacts').children().length === ko.toJS(self.Contacts).length) {
// Only now execute handler
jq();
}
}
}
ペイン関数changeNumber
から呼び出す方法は?jscroll
$('.jspScrollable').bind(
'jsp-arrow-change',
function(event, isAtTop, isAtBottom, isAtLeft, isAtRight) {
// Now look at the is* parameters and do what you
// need to do. All four of the is* parameters are booleans.
if(isAtBottom) {
ContactsViewModel.changeNumber();
}
}
);
データはサーバーから来ています
function returnData(url,data,type){
$.post(url, data, function(returnedData) {
if(type == "contacts")
{
ko.applyBindings(new ContactsViewModel(returnedData),$("#KnockOutContacts")[0]);
}
else if(type == "logs")
{
ko.applyBindings(new LogsViewModel(returnedData),$("#KnockOutLogs")[0]);
}
else if(type == "sms")
{
ko.applyBindings(new SmsViewModel(returnedData,"#KnockOutSms"),$("#KnockOutSms")[0]);
ko.applyBindings(new SmsViewModel(returnedData,"#KnockOutSmsData"),$("#KnockOutSmsData")[0]);
}
});
}
前もって感謝します。