knockout.js - Data-Binding issue with KO.js on modal control -
hi guys looking help data-binding issue have knockoutjs.
it started when ko.applybindings(viewmodel)
throwing me error on 1 page , not others saying multiple bindings beingness called on same element.
looking @ documentation fixed issue ko.applybindings(viewmodel, document.getelementbyid('elementid'))
code.
but problem problem has surfaced. lost binding on edit control. in other words when click on edit text blank dialog box instead of filled 1 object? properties.
original source code - https://dnnboards.codeplex.com/ original live demo - http://demo.dnnboards.com/
the difference can see knockoutjs version. original demo uses 2.1.0 , using 3.1.0 regardless if wrap entire demo html code in div <body> <div id="mymodule">...</div> <scripts> </body>
, change ko.applybindings(vm);
to ko.applybindings(vm, document.getelementbyid('mymodule'));
still works expected.
i couldn't work in jsfiddle should able improve thought of on about. http://jsfiddle.net/iiminov/88rafcfk/
if has suggestion of how go debugging i'd much appreciate it.
but suspecting that <div id="divmodal" style="display:none;"> <!-- ko with: selectedcard -->
not working correctly. because <!-- ko if: showaddcard --> <a href="#" class="hlcompose" data-bind="click: $root.expandcompose">add card</a>
displays add together card link on every list.
thanks @pw kad issue jsfiddle resolved. wasn't original question/problem trying solve.
as trying point out after adding scope ko.applybindings()
lost data-binding on dialog box able solve error multiple bindings on same element
.
jsfiddles' purpose demonstrate shouldn't having issues. yet struggling figure out why case.
however made few observations:
knockout version difference (demo 2.1.0 vs dev 3.1.0) i don't know plenty knockout rule 1 out becuase jsfiddle still works fine if bump knockout version 3.0.0 (latest available). i don't understand how data-binding works on dialog box in first place? i understandself.selectedcard = ko.observable();
declaration and undestand self.selectedcard(cardtoedit);
declaration but according documentation <p data-bind="with: coords">
shouldn't have <div id="divmodal" style="display: none;" data-bind="with: selectedcard">
(this doesn't work me btw) the same principal applies add card
link/button. i don't see binding with
keyword. however in original demo link nowadays on to do
list , in case nowadays on lists. update 1.1 scratch info binding bit with
keyword. found note 1: using “with” without container element
corresponds seeing in html. leading me believe not ok in javascript somewhere. <!-- ko with: outboundflight --> ... <!-- /ko -->
scratch out add card
link problem. turns out list items coming sortorder = 0 causes link display on every list.
well, have guessed fixing issue sortorder value not caused add card
link/button display on every list fixed problem data-binding on dialog box. hrm...
your fiddle first-class in diagnosing issue - http://jsfiddle.net/88rafcfk/1/ - there updated one.
it appears code working fine except single alter made - had document.getelementbyid
instead of document.getelementbyid
.
when changed worked fine.
knockout.js dotnetnuke
No comments:
Post a Comment