London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Hook to page-selected in EPiLink in TinyMCE

Vote:
0

Hey guys, I am creating a TinyMCE button - very similar to EPiLink button. I need to hook to page-selected/page-changed, this does not work:

linkEditor.on("fieldCreated", function (fieldname, widget) {

                                if ("href" === fieldname) {
                                    var hyperLinkSelector = widget,
                                        anchor = null,
                                        anchorWidget = getAnchorWidget(hyperLinkSelector.wrappers);
                                    anchorWidget && anchorWidget.length > 0 && (anchor = anchorWidget[0]), anchor && anchor.inputWidget ? anchor.inputWidget.set("selections", anchors) : widget.on("selectorsCreated", function (hyperLinkSelector) {
                                        var anchorWidget = getAnchorWidget(hyperLinkSelector.wrappers);
                                        anchorWidget && anchorWidget.length > 0 && anchorWidget[0].inputWidget && anchorWidget[0].inputWidget.set("selections", anchors)
                                    }), anchor && domStyle.set(anchor.domNode, {
                                        display: "block"
                                    });

                                    var page = null,
                                        pageWidget = getPageWidget(hyperLinkSelector.wrappers);
                                    pageWidget && pageWidget.length > 0 && pageWidget[0].inputWidget && pageWidget[0].inputWidget.onChange(function () {
                                        var test = "aaa";
                                    }) &&
                                    on(pageWidget[0].inputWidget, "onchanged", function() {
                                        var test2 = "bbb";
                                    })
                                    ;
                                }...

    

getPageWidget is similar as getAnchorWidget:

getPageWidget = function (widgetList) {
                                    return array.filter(widgetList, function (wrapper) {
                                        return "Page" == wrapper.name;
                                    });
                                }

and it is getting the correct widget, my hope is that the name of the event is wrong. Breakpoint doesn't get hit when I select the page in the tree and the dialog closes. If anyone knows how to hook to dialog closed from the same file, it's also of great help.

#84377
Apr 01, 2014 11:45
Vote:
0

None of these work:

pageWidget && pageWidget.length > 0 && pageWidget[0].inputWidget && pageWidget[0].inputWidget.onChange(function () {
                                        var mm = "test";
                                    }) &&
                                    on(pageWidget[0].inputWidget, "onchange", function() {
                                        var mm = "aaa";
                                    }) &&
                                    on(pageWidget[0].inputWidget, "changed", function () {
                                        var mm = "bbb";
                                    })
                                    &&
                                    on(pageWidget[0].inputWidget, "onselect", function () {
                                        var mm = "ccc";
                                    })
                                    &&
                                    on(pageWidget[0].inputWidget, "selected", function () {
                                        var mm = "ddd"
                                    })

    

#84378
Edited, Apr 01, 2014 11:49
Vote:
0

I have also tried with this:

var page = null,
    pageWidget = getPageWidget(hyperLinkSelector.wrappers);
    pageWidget && pageWidget.length > 0 && (page = pageWidget[0]) && page && page.inputWidget &&
    connect.connect(page.inputWidget.selectedContentLinkNode, "onchange", function () {
        var mm = "xx";
    });

    

and I've included dojo connect:

require([
                            "dojo/_base/lang",
                            "dojo/_base/array",
                            "dojo/on",
                            "dojo/when",
                            "dojo/dom-style",
                            "dojo/_base/connect",
                            "epi/dependency",
                            "epi/shell/widget/dialog/Dialog",
                            "epi-cms/ApplicationSettings",
                            "epi-cms/widget/LinkEditor",
                            "epi/i18n!epi/cms/nls/episerver.cms.widget.editlink"
                    ],
                        function (lang, array, on, when, domStyle, connect, dependency, Dialog, ApplicationSettings, LinkEditor, resource) {

    

#84398
Edited, Apr 01, 2014 15:25
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.