Jump to content

More than one function in a script failed


likemike

Recommended Posts

Hello!

I need some JS-scripts to address a UnimMemo.

I use Form->Script:

Ext.form.TextArea.prototype.deleteAtCursor = function(txt) {
    var val = this.getValue(),
        start = this.inputElement.dom.selectionStart,
        end = this.inputElement.dom.selectionEnd;

    this.setValue(val.substring(0, start - 1) + val.substring(end));
    this.inputElement.dom.selectionStart = this.inputElement.dom.selectionEnd = start - 1;
    Ext.defer(function() { this.focus(false); }, 10);
}

to do a backspace and it works!

I use Form->Script:

Ext.form.TextArea.prototype.insertAtCursor = function(txt) {
    var val = this.getValue(),
        start = this.inputElement.dom.selectionStart,
        end = this.inputElement.dom.selectionEnd;

    this.setValue(val.substring(0, start) + txt + val.substring(end));
    this.inputElement.dom.selectionStart = this.inputElement.dom.selectionEnd = start + txt.length;
    Ext.defer(function() { this.focus(false); }, 10);
} 

to insert text and it works, too!

But when I put both together in Form->Script, then an error occurs saying: "Ajax Error: unexpected identifier!"

Isn't it allowed to have more than one function in a script? Or is there a special syntax necessary?

I know, that these problems are based on my lack of understanding Sancha and JS, so it's very frustrating to have to ask every time things, that normally could be done on my own.

Thanks in advance

Link to comment
Share on other sites

  • likemike changed the title to More than one function in a script failed

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...