Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialogs not working in 4.3 #1408

Closed
cizo opened this issue Sep 23, 2019 · 22 comments
Closed

Dialogs not working in 4.3 #1408

cizo opened this issue Sep 23, 2019 · 22 comments
Labels
Milestone

Comments

@cizo
Copy link

cizo commented Sep 23, 2019

Hi after yesterday's update dialogs stop working, and when I try to open dialog, I only get message "Element not contain role dialog! Please add attribute data-role="dialog" to element #idDialog". There is data-role="dialog" in dialog for sure, as dialogs worked in older versions and rollback to ver. 4.2 helped as well.

@olton
Copy link
Owner

olton commented Sep 23, 2019

Show your dialog code and browser console

@cizo
Copy link
Author

cizo commented Sep 23, 2019

<div class="dialog" data-role="dialog" id="idDialog" data-close-button="true">
  <div class="dialog-title" id="idDialogTitle">Title</div>
  <div class="dialog-content" id="idDialogContent">
      <div class="row mb-2">
        <label class="cell-sm-2 d-none-touch" for="idname">Label:</label>
        <div class="cell-sm-10">
          <input type="text" id="idname" value="" disabled />
        </div>
      </div>
      <div class="row mb-2">
        <label class="cell-sm-2  d-none-touch" for="idclass">Class:</label>
        <div class="cell-sm-10">
          <input type="text" id="idclass" value="" />
        </div>
      </div>      
                         
  </div>
  <div class="dialog-actions">
    <button class="button success" id="idDialogOk">Ok</button>
    <button class="button" id="idDialogStorno">Storno</button>
  </div>  
</div>

console:
Element not contain role dialog! Please add attribute data-role="dialog" to element #idDialog metro.js:6367:21

@olton
Copy link
Owner

olton commented Sep 23, 2019

How you init the dialog?

@cizo
Copy link
Author

cizo commented Sep 23, 2019

HTML:
<button class="button primary small" onclick="OpenDialog()">Open</button>
SCRIPT:

function OpenDialog(id){
  Metro.dialog.open("#idDialog");
}

@olton
Copy link
Owner

olton commented Sep 23, 2019

the problem has been identified; now I am dealing with its solution. The problem is related to the interaction between Metro4 and jQuery. Thank you.

@olton
Copy link
Owner

olton commented Sep 23, 2019

Temporary, try this call:

function openDialog () {
     var dlg = $("#idDialog").data("dialog");
     dlg.open();
}

@cizo
Copy link
Author

cizo commented Sep 23, 2019

Thank you Olton. Im now using 4.2 version which is working, as soon as it will be fixed I'll return to using CDN version.

@olton
Copy link
Owner

olton commented Sep 23, 2019

About Metro 4 CDN
#1333

@olton olton added this to the v4.3.1 milestone Sep 23, 2019
@olton olton added bug Fixed and removed bug labels Sep 23, 2019
@olton
Copy link
Owner

olton commented Sep 23, 2019

You can check it with 4.3.1 branch from GitHub or CDN for 4.3.x dev

@olton olton closed this as completed Sep 25, 2019
@TomCorr
Copy link

TomCorr commented Nov 19, 2019

Hi, I just started using version 4.3.2, i had used Metro v3 in the past, I'm predefining a Dialog, and when i open the webpage, the dialog isn't hidden, and it has an OK button in it, when i init my Dialog it opens up fixed in the bottom of the page, and not in the center of the screen as it should.

in the Browser console it also says: "Element not contain role dialog! Please add attribute data-role="dialog" to element #AddUser".

@olton
Copy link
Owner

olton commented Nov 19, 2019

Upgrade to latest 4.3.3 release or 4.3.4 dev

@TomCorr
Copy link

TomCorr commented Nov 19, 2019

I Upgraded all files, Still no change..

@TomCorr
Copy link

TomCorr commented Nov 19, 2019

HTML:

<div data-overlay="true" data-close-button="true" data-overlay-click-close="true" data-overlay-color="ribbed-lightGray" id="AddUser" class="dialog" data-role="dialog"></div>

JS:

function AddUserDialog(id) {
    $("#AddUser").children().remove();

    $.ajax({
        method: "POST",
        url: window.$LoadUser,
        data: { userId: id },
        success: function (result) {
            $("#AddUser").append(result);
            Metro.dialog.open('#AddUser');
        }

    });
}

@olton
Copy link
Owner

olton commented Nov 19, 2019

This demo with 4.3.3 from CDN

https://codepen.io/olton/pen/ZEEwrMw
All works fine. Check your code for other errors.

@olton
Copy link
Owner

olton commented Nov 19, 2019

Also, you must use setContent API method to change dialog content:

$.ajax({
      ...
      success: function(result){
           var dialog = Metro.getPlugin('#AddUser', 'dialog');
           dialog.setContent(result);
           dialog.open(); // or Metro.dialog.open('#AddUSer')      
      }
})


@TomCorr
Copy link

TomCorr commented Nov 19, 2019

I'll follow your recommendations and notify you, thanks.

@TomCorr
Copy link

TomCorr commented Nov 19, 2019

dialog.setContent() sends me an error, dialog is undefined. I believe getPlugin() is not returning anything from script.

@olton
Copy link
Owner

olton commented Nov 19, 2019

Create your code on codepen.io

@TomCorr
Copy link

TomCorr commented Nov 19, 2019

Thank you for suggestion: I found problem: I deleted: data-overlay-color="ribbed-lightGray"

and now everything works

@TomCorr
Copy link

TomCorr commented Nov 19, 2019

Only there is always an OK button i do not want

@olton
Copy link
Owner

olton commented Nov 19, 2019

data-default-action="false"

@TomCorr
Copy link

TomCorr commented Nov 19, 2019

Thank you for all your support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants