javascript - Sails.js - How to render a partial from a controller? -
i have partial view containing login form. render ajax call controller.
this sample return partial view:
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 want return partial view, not view res.view('home/login', {message: 'login success!'}); }else{ // here want return partial view, not view res.view('home/login', {message: 'login failed!'}); } }); },
ah! found it!
if view partial view, specify layout: null
:
res.view('home/login', {message: 'login failed!', layout: null});
Comments
Post a Comment