Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show alerts/popups/windows using knockout.js

Tags:

knockout.js

I think we shouldn't have references to html elements in viewmodel. So I think I can't do $('#id').dialog() or shouldn't do alert('message') or window.open(). Then how should I do it?

like image 918
Piotr Perak Avatar asked Jan 18 '23 23:01

Piotr Perak


1 Answers

Take a look at this answer for a sample of using a custom binding to control a jQuery UI dialog from your view model.

integrating jquery ui dialog with knockoutjs

Setting an observable to true opens the dialog, setting it to false closes it.

like image 145
RP Niemeyer Avatar answered Jan 21 '23 13:01

RP Niemeyer