How to bind value in MVC using knockout JS (MVVM) Summernote editor


Hardik

I have successfully integrated summernote editor in mvc project but can't get value from textarea.

I have used knockout (MVVM) structure.

<tbody data-bind='with:demo'>
     <textarea class="summernote" placeholder="Description" data-bind='value:   Description'></textarea>
</tbody>

var Demo = function (demo) {
var self = this;
self.Description = ko.observable(demo? demo.Description : '');
 }

var DemoViewModel = function () {
   var self = this;
   self.demo= ko.observable(new Demo());
 }

ko.applyBindings(new DemoViewModel ())
Gerjo

The problem has to do with html and how the browser will render it.

your sample

<tbody data-bind='with:demo'>
    <textarea class="summernote" placeholder="Description" data-bind='value: Description'></textarea>
</tbody>

presented as. tbodyDeleted, knockout can't find Descriptionbinding

<textarea class="summernote" placeholder="Description" data-bind="value: Description"></textarea>

See jsfiddle for more information . The problem is related to the automatic insertion of the tbody tag by the browser (which in your case removes the tag). This is a similar question , butforeach

You can fix this problem as follows

<table>
    <tbody data-bind="with:demo">
        <tr>
            <td>
                <textarea placeholder="Description" data-bind="value: Description"></textarea>
            </td>
         </tr>
    </tbody>
</table>

See jsfiddle for more information .

or add divtags ( jsfiddle )

<div data-bind="with:demo">
    <tbody>
        <textarea placeholder="Description" data-bind="value: Description"></textarea>
    </tbody>
</div>

Note: tbodywill not exist in the resulting html

Related


How to get input in summernote editor using jQuery?

Allen I have used Summernote editor. I am able to get the editor but not the data entered in the editor. I have followed the instructions in this url but I cannot get the entered data in the editor when the button is clicked. Who can help me with this? thanks

How to bind last index value of observable array in knockout js

what I need to display the latest comment to the user when the front page loads, like after adding a new comment, the new comment is successfully added to the observable array, but I am not able to display the latest comment, I am trying this code and it doesn

How to bind multiple images to graphic elements using knockout.js

happy I would like to use knock to generate the output below. <figure data-bind="?"> <img src="a.jpg" /> <img src="b.jpg" /> <img src="c.jpg" /> ...... ....... <figcaption>Image title</figcaption> </figure> <img />There are many elements , only one figcaption

How to bind multiple images to graphic elements using knockout.js

happy I would like to generate the output below with gene knockout. <figure data-bind="?"> <img src="a.jpg" /> <img src="b.jpg" /> <img src="c.jpg" /> ...... ....... <figcaption>Image title</figcaption> </figure> There are many <img />elements, only one figca

How to bind multiple images to graphic elements using knockout.js

happy I would like to generate the output below with gene knockout. <figure data-bind="?"> <img src="a.jpg" /> <img src="b.jpg" /> <img src="c.jpg" /> ...... ....... <figcaption>Image title</figcaption> </figure> There are many <img />elements, only one figca

WPF how to bind value to TextBox using MVVM pattern correctness

Marvin Klein I am currently trying to use WPF. I created a demo project using Windows Template Studio for Visual Studio. Now I want to add a textbox which should be autosaved by the MVVM pattern. I have added the following XAML in my settings page. <TextBlock

WPF how to bind value to TextBox using MVVM pattern correctness

Marvin Klein I am currently trying to use WPF. I created a demo project using Windows Template Studio for Visual Studio. Now I want to add a textbox which should be autosaved by the MVVM pattern. I have added the following XAML in my settings page. <TextBlock

WPF how to bind value to TextBox using MVVM pattern correctness

Marvin Klein I am currently trying to use WPF. I created a demo project using Windows Template Studio for Visual Studio. Now I want to add a textbox which should be autosaved by the MVVM pattern. I have added the following XAML in my settings page. <TextBlock

WPF how to bind value to TextBox using MVVM pattern correctness

Marvin Klein I am currently trying to use WPF. I created a demo project using Windows Template Studio for Visual Studio. Now I want to add a textbox which should be autosaved by the MVVM pattern. I have added the following XAML in my settings page. <TextBlock

WPF how to bind value to TextBox using MVVM pattern correctness

Marvin Klein I am currently trying to use WPF. I created a demo project using Windows Template Studio for Visual Studio. Now I want to add a textbox which should be autosaved by the MVVM pattern. I have added the following XAML in my settings page. <TextBlock