knockout.js - Knockout vs jQuery plugins - should they both be used? -
i'm working on legacy web application built plugins reusable modules. example - when developer needs take standard input box , append dropdown next modifies contents of input box (currency, example, adding $), developer call $(#input).currencydropdown(settings)
, appends html (the select
array of options) within plugin , detects changes / handles updates using standard jquery, no knockout.
the goal of existing pattern reduce copying of code - both markup , js logic. i'm trying push app more towards knockout / mvvm, i'm not sure if excludes plugin use. feel should somehow replacing target input
data-bound template. challenge here in places, have input
, cannot update dom unless it's via plugin.
i've seen custom binding handlers used logic / styling, in terms of appending actual html markup, custom binding handler right way go? should templates come play, if @ all, when reusing pattern across multiple viewmodels in different areas of application?
as example, have input not knockout data-bound:
<input>
the goal to, within plugin, change data-bound snippet:
<input data-bind='value: amount'><select data-bind='stuff here'>
where amount
computed observable dependent on what's selected. bonus, depending on what's selected, popup may need displayed.
what's recommended strategy around knockout-ifying application within above constraints?
yes, custom binding handlers way go.
Comments
Post a Comment