Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
Getting Error: You cannot apply bindings multiple times to the same element in OJET

Below is my HTML code to open oj-dialog

<div id="dialogWrapper">
    <div style="display:none" id="modalDialog1" title="Modal Dialog" data-bind="ojComponent:{component: 'ojDialog',
                                 initialVisibility: 'hide',
                                 open: dialogOpen,
                                 close: dialogClose,
                                 rootAttributes: {
                                   class: 'animate'
                                 }}">
      <div class="oj-dialog-body">
        The dialog window can be moved, resized and closed with the 'x' icon.
        Arbitrary content can be added to the the oj-dialog-body and oj-dialog-footer sections.
      </div>
      <div class="oj-dialog-footer">
        <button id="okButton" data-bind="click: closeDialog,
                                           ojComponent: {component: 'ojButton',
                                                         label: 'OK'}"> </button>
      </div>
    </div>
    <button id="buttonOpener" data-bind="click: openDialog,  
                                         ojComponent: {component: 'ojButton',
                                                       label: 'Open Modal Dialog'}"></button>

  </div>

Below is my corresponding js code :

define(['require', 'exports', 'knockout', 'ojs/ojbootstrap', 'ojs/ojknockout', 'ojs/ojbutton', 'ojs/ojdialog'],
function(ko, oj, $) {
  'use strict';

  var ViewModel = function() {
    var self = this;

    self.openDialog = function() {
      $("#modalDialog1").ojDialog("open");
    };
    
    self.closeDialog = function(data, event) {

            // attempt fadeOut with jQuery
      $(event.target)
        .closest(".oj-dialog.animate")
        .fadeOut(function() {
          console.log("faded out", this);
          $("#modalDialog1").ojDialog("close");
        });
      };

    self.dialogOpen = function(event, ui) {
      $(event.target)
        .closest(".oj-dialog.animate")
        .addClass("fully-opaque");
    };

    self.dialogClose = function(event, ui) {
      $(event.target)
        .closest(".oj-dialog.animate")
        .removeClass("fully-opaque");
    };

  };

  ko.applyBindings(new ViewModel());
});

When I run this code I am getting "Error: You cannot apply bindings multiple times to the same element." error. I am new to development and as per document I have added all libraries. Can Anyone see where its going wrong.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda