Confirmation dialog and the MVVM pattern

819 views
Skip to first unread message

José F. Romaniello

unread,
Aug 11, 2011, 8:43:54 AM8/11/11
to KnockoutJS
Hi everyone, I am doing my first steps in knockoutJs and I like it so
far.

Here is my problem, I have a form which has the submit binding is
bound to an function in the viewmodel. Yesterday we decide that we
need to show a confirmation dialog, before doing the ajax post.

A-So, my first question is conceptually speaking, if a "confirmation
dialog" is a view concern or a viewmodel concern?

My thoughts on this, is that it is a presentation concern so I tried
to keep this out from my viewmodel-

And I decide to do something like this http://jsfiddle.net/fNCBa/7/
(it is not working) instead of doing
data-bind="submit: save...",

I am doing:
data-bind="confirmAndSubmit: {template: '#MyConfirmTemplate', data:
items, submit: save}"

B-Does this seems right?
C-If this is right, is there a way I can use knockout template engine
from my code.. to render the content of the dialog?
D-If this doesn't seem right, how would you do it?


Thank you very much!

Scott Messinger

unread,
Aug 11, 2011, 12:07:36 PM8/11/11
to knock...@googlegroups.com
I also put the alert/confirm dialog box in the save action in my viewmodel.

iandra...@gmail.com

unread,
Aug 11, 2011, 2:13:38 PM8/11/11
to knock...@googlegroups.com
Here a sample that should help, specifically the delete button functionality.  Though, your needs maybe more simple.

José F. Romaniello

unread,
Aug 11, 2011, 2:32:51 PM8/11/11
to knock...@googlegroups.com
Excelent! thank you very much you both... 
The final version of my example working is http://jsfiddle.net/U2wEh/23/ 

now we have three different approach for this
Reply all
Reply to author
Forward
0 new messages