English 中文(简体)
如何在这种匿名的javascript中称职? (TinyMce例)
原标题:How can i call that function inside that anonymous javascript? (TinyMce example)

如何在这种方法内进行电话测试? 它是可能的?

(function() {

    tinymce.create( tinymce.plugins.WrImagerPlugin , {

        init : function(editor, url) { 

            editor.addCommand( mceWrImagerLink , function() {
                //--> how can i refer to test() here?
            });
        },
        test: function () {alert( test );}
        }
    });

    tinymce.PluginManager.add( wr_imager , tinymce.plugins.WrImagerPlugin);
})();
最佳回答

您也可在<条码>中查阅<条码>。 可在<代码>addCommand上查阅的方法 关闭:

(function() {

tinymce.create( tinymce.plugins.WrImagerPlugin , {

    init : function(editor, url) { 
        var me = this;
        editor.addCommand( mceWrImagerLink , function() {
            //--> how can i refer to test() here?
            me.test();
        });
    },
    test: function () {alert( test );}
    }
});

tinymce.PluginManager.add( wr_imager , tinymce.plugins.WrImagerPlugin);

})();
问题回答

您可以将<条码>测试作为常规功能,并将其分配给物体,如:

(function() {
    function test() { alert( test ); }

    tinymce.create( tinymce.plugins.WrImagerPlugin , {
        init : function(editor, url) { 
            editor.addCommand( mceWrImagerLink , function() {
                test();
            });
        },
        test: test
    });

    tinymce.PluginManager.add( wr_imager , tinymce.plugins.WrImagerPlugin);
})();

或者,你可以提及该目标:

(function() {
    var wrImaergPlugin = {    
        init : function(editor, url) { 
            editor.addCommand( mceWrImagerLink , function() {
                wrImagerPlugin.test();
            });
        },
        test: function() { alert( test ); }
    }

    tinymce.create( tinymce.plugins.WrImagerPlugin , wrImagerPlugin);
    tinymce.PluginManager.add( wr_imager , tinymce.plugins.WrImagerPlugin);
})();

最后,在这种具体情况下,你应当能够简单地打上<条码>,即“条码”。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签