Home API Docs Linkr Client Side Javascript
Attention: open in a new window.PDFPrintEmail
Article Index
Javascript
Variables
Basic
Strings
Database
HTML
Miscellanous
All Pages

Basic methods

Here are the basic methods you should know when writing your plugin.

getError()

Since 2.3.1 Returns the last known error

getAllErrors()

Since 2.3.1 Returns an array of reported errors

getSelectedText(html)

Retrieves the highlighted text from the article
  • html (optional): Return raw HTML instead of plain text

getDefaultText(text)

Same as LinkrHelper.getSelectedText, but returns the passed argument if no text was selected
  • text (required): Default text if no text was selected by user

insert(text)

Inserts text into the article at the cursor's position, replacing any highlighted text
  • text (required): The text to insert into the article

insertAtEnd(text)

Inserts text at the end of an article, ignoring any highlighted text
  • text (required): The text to insert into the article

link(url, text)

Shortcut to insert a link and close the lightbox
  • url (required): URL to link
  • text (required): Link text
  • This method assumes that DOM elements with the following IDs exist:
    • target
    • linkTitle
    • linkClass
    • linkRelation

setReturnPage(func)

Since 2.3.1 Sets the page to load when Linkr is opened. Useful if user needs to insert several links and come back to the same page
  • func (required): Function to call. Can be an array containing an object and method
NOTE: A function should be supplied as a string e.g. 'myFunction' and an object as an array of strings e.g. ['myObject', 'myMethod'].


uBar 0.9 has been released. This is a beta version; there are still some bugs to be worked out. Keep that in mind before using it on a live site.