Reputation: 61
I have two drop down lists in my form. Once user selected value from first list I want to filter second list as per selection and display. For that I am using onchange="showSubCat(); of first select option to get selected value. showSubCat() function is defined in client side js file. How do I get value returned by showSubCat() function in jade template so that I can filter array which is populating second list.
var subcode = showSubCat();
gives error.
Any suggestions? Thank you.
Upvotes: 5
Views: 7755
Reputation: 9584
New to Jade myself but as far as I can tell you have two options:
1) create the function in jade itself:
-function sayHi(name){
- return "hello "+name
-}
p= sayHi('bill')
Which I think muddies up your code a bit.
2) A better option would be to pass in the function from the model
app.get('/', function(req, res){
res.render('home', {
title: 'Home'
, fs: { sayHi:function(name){
return "hello "+name
}}
});
});
Then in your jade file you just:
p= fs.sayHi('bill')
Upvotes: 4