A few questions regarding polymer best practices

I am building my first single-page Polymer application and I have a few questions.

1) In many views, I need to show a dialog (various confirmations, etc.), and I tried to centralize the dialogs by creating a dialog in the parent. The contents of the dialog switches to the pages of iron. Here is the code in the parent:

<paper-dialog id="main_dialog" with-backdrop entry-animation="scale-up-animation"
              exit-animation="fade-out-animation">
    <iron-pages id="dialogpages" selected="login" attr-for-selected="name">
        <login-view name="login"></login-view>
        <registration-view name="registration"></registration-view>
        <emaildialog-view name="emaildialog"></emaildialog-view>
        <actionerror-view name="actionerror"></actionerror-view>
        <actionconfirm-view name="actionconfirm"></actionconfirm-view>
        <passreset-view name="passreset"></passreset-view>
        <emailinput-view name="emailinput"></emailinput-view>
    </iron-pages>
</paper-dialog>

And javascript:

    showDialog: function (path, pageName, open) {
        this.$.dialogpages.selected = pageName;
        this.importHref("/views/dialog_views/" + path + pageName + "-view.html", function () {
            if (open) {
                this.$.main_dialog.toggle();
            }
        }.bind(this), null, true);

    },

However, as the application grows, the code becomes messy. Do you think it would be better to import a paper dialog box in the subitems and show them there?

2) , . , -. 1, 2 3. .

, (, this.domHost.step1 = data) . , , iron-meta?

3) SOLVED: .

, (, this.domHost.showDialog()), , .

, ( ), , , DOM.

EDIT: . .

,

+4
1

, , . , <file-location> <file-location-dialog>. <file-location> dom-repeat , , , <file-location-dialog> - , .

, <file-location> . <file-location-dialog> domHost positionTarget event.path[0] . , , .

, positionTarget .

, .

Polymer 1.0, - - v1.0 , event.path[0] event.composedPath()[0] , "" ( )

, , .

+1

Source: https://habr.com/ru/post/1662605/


All Articles