Home Search Member List Faq Register Login  
UltimateSpellMVC
UltimateSpell + knockout

Thread Starter: mpec   Started: 03-06-2013 7:13 AM   Replies: 3
 Karamasoft Support Forums » General Discussions » UltimateSpellMVC » UltimateSpell + knockout
 Printable Version    « Previous Thread   Next Thread »
  06 Mar 2013, 7:13 AM
mpec is not online. Last active: 3/6/2013 3:33:15 PM mpec

Not Ranked
Joined on 03-06-2013
Posts 2
UltimateSpell + knockout
Hello,

I am using Ultimate Spell on a page that tracks it's changes via knockout. When some words are changed everything appears to look fine but the 'change' event is not fired. I update the server side when the change event occurs. How does the UltimateSpell change the value of the inputs it works with? Is there a way to subscribe to those change events? Or maybe somehow trigger change event for each field that was changed via UltimateSpell?

  
  06 Mar 2013, 2:17 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: UltimateSpell + knockout
When you enable the SpellAsYouType property, your textboxes become virtually hidden and replaced by SpellAsYouType areas. Therefore, the user events will not be detected and KO will not update the property on your view model. To overcome this, you can add an onblur event handler on the original textbox and programmatically set the observable value accordingly as follows:

<p>First name: <input id="firstName" type="text" onblur="HandleBlur(this);" data-bind="value: firstName" /></p>
<p>Last name: <input id="lastName" type="text" onblur="HandleBlur(this);" data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>

<script type="text/javascript">
function HandleBlur(obj) {
viewModelObj[obj.id](document.getElementById(obj.id).value);
}

var ViewModel = function (first, last) {
this.firstName = ko.observable(first);
this.lastName = ko.observable(last);
this.fullName = ko.computed(function () {
return this.firstName() + " " + this.lastName();
}, this);
};

var viewModelObj = new ViewModel("Planet", "Earth");

ko.applyBindings(viewModelObj);
</script>

  
  06 Mar 2013, 3:33 PM
mpec is not online. Last active: 3/6/2013 3:33:15 PM mpec

Not Ranked
Joined on 03-06-2013
Posts 2
Re: UltimateSpell + knockout
Thanks for your answer, but I think I should have been more clear with my question because the problem is a bit different.

I have a table that holds dynamically added items by the user. Let's say that each table line consists of Title and Description. The items are editable inline (so there are two inputs each table row). The users enters the page and they have some data that they filled in earlier. Then the user clicks a button that shows the spellchecker dialog (there is no inline spell checking on the inputs). Then he corrects some words and clicks ok. At this moment the values in the inputs are replaced by the corrected values. And this is the place I am interested in. Is there a way to get a list of those inputs that are about to have their values changed?

The reason I need this is that I have an autosaving grid and it saves (to the server side) on the 'change' event. The change event is not triggered when the input value is changed via javascript (obviously). So if I am able to raise the change event on each of the inputs that were changed by the spell check dialog I would not have to write tons of code which only purpose is to detect wheather the dialog changed something. And it can be problematic as there are pages with numerous knockout grids on one page.

  
  06 Mar 2013, 4:00 PM
Karamasoft is not online. Last active: 5/8/2018 10:36:45 AM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,820
Re: UltimateSpell + knockout
Unfortunately, UltimateSpell doesn't provide a client-side API to return a list of input controls that have their values changed through the spell check dialog box. You need to create your own handlers on Spell Check button click and when the dialog box is closed by the OK click, which you can customize in UltimateSpellInclude\UltimateSpell.spell.htm.
  
 Page 1 of 1 (4 items)
Karamasoft Support Forums » General Discussions » UltimateSpellMVC » UltimateSpell + knockout

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.