Skip to content

Not working with checkboxes #4

@ponasromas

Description

@ponasromas

Trying to use this on checkbox with twitter bootstrap:

<input class="form-check-input" rel="confirm" type="checkbox" role="switch" id="2faon" name="2fa" value="1">

Nothing happens... JS part:

// cxdialog
    document.body.addEventListener('change', (e) => {
        const el = e.target;
        const nodeName = el.nodeName.toLowerCase();
    
        if (nodeName === 'input' && el.rel) {

          const rel = el.rel;
    
          switch (rel) {
            case 'alert':
              cxDialog('Hello World<br>I am cxDialog');
              break;
    
            case 'ok':
              cxDialog({
                info: '现在开始使用 <strong>cxDialog</strong>',
                ok: () => {
                  console.log('确定');
                }
              });
              break;
    
            case 'confirm':
              cxDialog({
                info: '现在开始使用 <strong>cxDialog</strong>',
                ok: () => {
                  console.log('确定');
                },
                no: () => {
                  console.log('取消');
                },
              });
              break;
    
            case 'article':
              const opts = {
                info: Array(99).fill('文章内容'),
                buttons: []
              };
    
              opts.info.unshift('<div style="width:9999px;background:linear-gradient(to right,rgba(0,0,0,1) 0%,rgba(0,0,0,0.1) 100%);color:#fff;">超宽内容</div>');
              opts.info = opts.info.join('<br>');
    
              for (let i = 0; i < 9; i++) {
                opts.buttons.push({
                  text: '按钮' + i,
                  callback: () => {
                    console.log('按钮' + i)
                  }
                });
              };
    
              cxDialog(opts);
              break;
    
            case 'text':
              formOptions.info.innerHTML = '<div class="setvalue"><input name="name" type="text"></div>';
              cxDialog(formOptions);
              break;
    
            case 'radio':
              createOptions('radio');
              cxDialog(formOptions);
              break;
    
            case 'checkbox':
              createOptions('checkbox');
              cxDialog(formOptions);
              break;
    
            case 'login':
              cxDialog(formOptions);
              break;
          };
        };
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions