This is a migrated thread and some comments may be shown as answers.

Cannot find a way to trigger binding with parameter

2 Answers 27 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Hermann
Top achievements
Rank 1
Hermann asked on 30 Apr 2019, 11:58 AM

I have a tag like this
<button data-bind="attr: { data-placeholder: Placeholder(512) }" />

Usually I trigger the change like this: model.trigger('change', { field: 'Placeholder'}) but this doesn't work in this case.

Could anyone help me?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Hermann
Top achievements
Rank 1
answered on 02 May 2019, 06:37 AM
Have found the Solution, thanks.
0
Dimitar
Telerik team
answered on 02 May 2019, 07:06 AM
Hello Hermann,

I have prepared a Dojo example that demonstrates a similar scenario to the one described - programmaticaly triggering the view model change. With it, the change handler of the view model is being successfully executed with the following code:
<div id="example">
  <button class="k-button"
   data-bind="attr: { data-placeholder: Placeholder(512) }"
   style="width: 180px">Click me
  </button>
</div>
 
<script>
  var viewModel = kendo.observable({
    Placeholder: function(val) {
      this.trigger('change', { field: 'Placeholder'})
      return val;
    }
  });
   
  viewModel.bind("change", function (e) {
    alert("changed");
  });
   
  kendo.bind($("#example"), viewModel);
</script>

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MVVM
Asked by
Hermann
Top achievements
Rank 1
Answers by
Hermann
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or