I plan on using multiple popups on my website. Every popup will be rendered by a different view. How can I share certain events, like clicking outside of the popup to close it, across these multiple views that each use a popup?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using backbone’s built-in extend could be a good fit for this. You could have a base view like so:
And all your other popups could extend the base popup:
It’s worth noting that any properties including
eventsthat you specify in a child view will override the properties in the parent. To avoid this, you’ll need to either merge the parent’s values (in the case of events) or set them programmatically usingdelegateEvents(documentation).