开发者

Troubles with function calling

I'm using EditArea editor. There is function: editAreaLoader.execCommand, it receives id of editor and command with arguments. So the code:

$(document).ready(function() {
   // Call go to line function after click at button
   $('#line_go').click(function() {
      console.log($('#line_to').val());
      editAreaLoader.execCommand('example_1', 'go_to_line', $('#line_to').val());
    });

    // Try to do the same but after loading of the page
    editAreaLoader.execCommand('example_1', 'go_to_line',$('#line_to').val() );
});

HTML:

<input type="edit" name="line" id="line_to" value="15" /> 
<input type="button" name="line_go" id="line_go" value="Go开发者_JS百科" />

So, when the page loads nothing happens. But when I click at button editor goes to line #15 (or something else if I change it). console.log shows 15.

When I wrap execCommand (second, which is called after page loading) with alert, for example, it returns false.

What's wrong is there? Why does call after page loading returns false? Thanks.


It looks like $(document).ready(...) fires before your EditArea instance has finished initialising itself. When you fire the click event on #line_go it is after the EditArea instance has initialised and is therefore able to retrieve information about it or perform actions upon it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜