Tôi có một chế độ xem một phần chứa biểu mẫu đăng nhập của tôi. Tôi muốn làm cho nó từ một cuộc gọi ajax để điều khiển của tôi.Sails.js - Làm cách nào để hiển thị một phần từ bộ điều khiển?
Đây là mẫu nơi tôi sẽ quay trở lại xem một phần của tôi:
postlogin: function (req,res) {
var username = req.param('username');
var password = req.param('password');
User.find({
username: username,
password: password.salt()
}).done(function(err, users){
if(users.length == 1){
// Here I want to return a partial view, not a view
res.view('home/login', {message: 'Login success!'});
}else{
// Here I want to return a partial view, not a view
res.view('home/login', {message: 'Login failed!'});
}
});
},
Yep! Và nếu bạn muốn vô hiệu hóa bố cục trên toàn cầu (thực hiện các công cụ Express-3-ish một phần-ish cách) bạn có thể đặt 'layout: false' trong tệp' config/views.js' của bạn. – mikermcneil