knockout.js - HotTowel modal dialog -
recently, started first visual studio knockout/breeze app using 1 of templates found online, , wanted modal dialog open similar this:
<a href="#openmodal">open modal</a> <div id="openmodal " class="modaldialog"> <a href="#close" title="close" class="close">x</a> <div data-bind="foreach: userdetails"> <p>user details go here</p> <p data-bind="text: $data.name" /> <p data-bind="text: $data.role" /> </div> </div>
here css
.modaldialog { position: fixed; font-family: arial, helvetica, sans-serif; color:#ffffff; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,0.8); border:2px solid #4cff00; z-index: 99999; opacity:0; -webkit-transition: opacity 400ms ease-in; -moz-transition: opacity 400ms ease-in; transition: opacity 400ms ease-in; pointer-events: none; } .modaldialog:target { opacity:1; pointer-events:stroke; } .modaldialog > div { width: 400px; position: relative; margin: 10% auto; padding: 5px 20px 13px 20px; border:1px solid; border-color: #fee209; border-radius: 1px; background: #b5a526; background: -moz-linear-gradient(#b5a526, #000); background: -webkit-linear-gradient(#b5a526, #000); background: -o-linear-gradient(#b5a526, #000); } .close { background: #ffffff; color: #204510; line-height: 25px; position: absolute; right: -12px; text-align: center; top: -10px; width: 24px; text-decoration: none; font-weight: bold; -webkit-border-radius: 12px; -moz-border-radius: 12px; border-radius: 12px; -moz-box-shadow: 1px 1px 3px #000; -webkit-box-shadow: 1px 1px 3px #000; box-shadow: 1px 1px 3px #000; } .close:hover { background: #00d9ff; }
this worked fine, i'm attempting implement knockout/breeze application hottowel. when click on link button, warning of 'no route found', , no pop-up. gather hottowel thinks i'm trying navigate somewhere, there way tell not in instance? or because hottowel uses html instead of cshtml views? can not way hottowel?
of course thinks trying navigate, did expect
<a href="#close" title="close" class="close">x</a>
if not navigation? that's anchor tags do when have href
attribute. you're getting route exception instead of 404 because navigation intercepted router , #close
doesn't match of routes have defined, doesn't change underpinning problem.
if want click handler should define click handler instead of navigation anchor.
write js function in scope. sensible place method of view-model, since validation requires access collected data hope binding view-model.
then bind it. can keep anchor tag if it's important styling, replace href
attribute data-bind="click: yourvm.themethod"
or (assuming put method on vm) can use binding reference $root.themethod
. use relative reference , if don't know is, encourage do tutorials.
Comments
Post a Comment