cakephp-1.3 > AjaxHelper :: link()
A AclBase AclBehavior AclComponent AclNode AclShell Aco AcoAction AjaxHelper ApcEngine ApiShell App AppController AppController AppHelper AppHelper AppModel AppModel Aro AuthComponent B BakeShell BakeTask BehaviorCollection C Cache CacheEngine CacheHelper CakeErrorController CakeLog CakeRoute CakeSchema CakeSession CakeSocket ClassRegistry Component Configure ConnectionManager ConsoleShell ContainableBehavior Controller ControllerTask CookieComponent D DataSource DbAcl DbAclSchema DbConfigTask DboMssql DboMysql DboMysqlBase DboMysqli DboOracle DboPostgres DboSource DboSqlite Debugger Dispatcher E EmailComponent ErrorHandler ErrorHandler ExtractTask F File FileEngine FileLog FixtureTask Folder FormHelper H Helper HtmlHelper HttpSocket I I18n I18nModel i18nSchema I18nShell Inflector IniAcl J JavascriptHelper JqueryEngineHelper JsBaseEngineHelper JsHelper L L10n M MagicDb MagicFileResource MediaView MemcacheEngine Model ModelBehavior ModelTask MootoolsEngineHelper Multibyte N NumberHelper O Object Overloadable Overloadable Overloadable2 Overloadable2 P PagesController PagesController PaginatorHelper Permission PluginShortRoute PluginTask ProjectTask PrototypeEngineHelper R RequestHandlerComponent Router RssHelper S Sanitize Scaffold ScaffoldView SchemaShell Security SecurityComponent SessionComponent SessionHelper SessionsSchema Set Shell ShellDispatcher String T TemplateTask TestSuiteShell TestTask TextHelper ThemeView TimeHelper TranslateBehavior TreeBehavior V Validation View ViewTask X XcacheEngine Xml XmlElement XmlHelper XmlManager XmlNode XmlTextNode

link

line:213 at /cake/libs/view/helpers/ajax.php
Returns link to remote action

Method

(string) link ($title, $url = null, $options = array(), $confirm = null)

Parameters

ParameterTypeCommentDefault
$title string required Title of link
$url mixed optional Cake-relative URL or array of URL parameters, or external URL (starts with http://) null
$options array optional Options for JavaScript function array()
$confirm string optional Confirmation message. Calls up a JavaScript confirm() message. null

Return

string

Comment

Returns link to remote action

Returns a link to a remote action defined by <i>options[url]</i>
(using the url() format) that's called in the background using
XMLHttpRequest. The result of that request can then be inserted into a
DOM object whose id can be specified with <i>options[update]</i>.

Examples:
<code>
link("Delete this post",
array("update" => "posts", "url" => "delete/{$postid->id}"));
link(imageTag("refresh"),
array("update" => "emails", "url" => "list_emails" ));
</code>

By default, these remote requests are processed asynchronous during
which various callbacks can be triggered (for progress indicators and
the likes).

Example:
<code>
link (word,
array("url" => "undo", "n" => word_counter),
array("complete" => "undoRequestCompleted(request)"));
</code>

The callbacks that may be specified are:

- <i>loading</i>:: Called when the remote document is being
loaded with data by the browser.
- <i>loaded</i>:: Called when the browser has finished loading
the remote document.
- <i>interactive</i>:: Called when the user can interact with the
remote document, even though it has not
finished loading.
- <i>complete</i>:: Called when the XMLHttpRequest is complete.

If you for some reason or another need synchronous processing (that'll
block the browser while the request is happening), you can specify
<i>options[type] = synchronous</i>.

You can customize further browser side call logic by passing
in Javascript code snippets via some optional parameters. In
their order of use these are:

- <i>confirm</i>:: Adds confirmation dialog.
-<i>condition</i>:: Perform remote request conditionally
by this expression. Use this to
describe browser-side conditions when
request should not be initiated.
- <i>before</i>:: Called before request is initiated.
- <i>after</i>:: Called immediately after request was
initiated and before <i>loading</i>.

@param string $title Title of link
@param mixed $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
@param array $options Options for JavaScript function
@param string $confirm Confirmation message. Calls up a JavaScript confirm() message.

@return string HTML code for link to remote action
@link http://book.cakephp.org/view/1363/link