Cannot find a way to trigger binding with parameter

3 posts, 0 answers
  1. Hermann
    Hermann avatar
    5 posts
    Member since:
    Jan 2018

    Posted 30 Apr Link to this post

    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. Hermann
    Hermann avatar
    5 posts
    Member since:
    Jan 2018

    Posted 02 May in reply to Hermann Link to this post

    Have found the Solution, thanks.
  3. Dimitar
    Admin
    Dimitar avatar
    686 posts

    Posted 02 May Link to this post

    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.
Back to Top