Project

General

Profile

Enhancement(機能追加・改善) #4183

Updated by Shinichi Urabe over 5 years ago

h3. 概要

JS から app_url_for, url_for などのヘルパーの結果を問い合わせる機構の作成

h3. 仕様

h4. opUrl.app_url_for

h5. jsDoc

<pre>
<code class="javascript">
/**
* method app_url_for().
*
* @param {strina} application ex: pc_frontend, api ...
* @param {string} internalUri 'module/action' or '@rule' of the action
* @param {boolean} absolute return absolute path?
* @returns {Deferred} Return a Deferred's Promise object. opUrl.url_for(... snip ...).done(function(url) {... snip ...}).fail(function(xhr, textStatus, errorThrown) {... snip ...}) @param {object} callback {success: function(result) {}, error: function(error) {}}
*/
</code>
</pre>

h5. code example.

<pre>
<code class="javascript">

// no problem url.
opUrl.app_url_for(
'api',
'@homepage',
false
).done(function(url)
false,
{ 'success': function (url) { console.log(url); }); } }
);


// -> /api.php/

// invalidUrl
opUrl.app_url_for(
'api',
'@invalidUrl',
false
).done(
false,
function(url) {
'success': function (url) {
console.log(url); }
).fail(
},
'error':
function(xhr, textStatus, errorThrown) { console.log(xhr, textStatus, errorThrown); }
}

);

// -> xhr object, status, error

</code>
</pre>

h4. opUrl.url_for

for pc_frontend.

h5. jsDoc

<pre>
<code class="javascript">
/**
* method url_for(). app_url_for().
*
* @param {string} internalUri 'module/action' or '@rule' of the action
* @param {boolean} absolute return absolute path?
* @returns {Deferred} Return a Deferred's Promise object. opUrl.url_for(... snip ...).done(function(url) {... snip ...}).fail(function(xhr, textStatus, errorThrown) {... snip ...}) @param {object} callback {success: function(result) {}, error: function(error) {}}
*/
</code>
</pre>

h5. code example.

<pre>
<code class="javascript">

// no problem url.
opUrl.url_for(
'@homepage',
true,
).done(function(url)

{ 'success': function (url) { console.log(url); }); } }
);


// -> http://example.com/

// invalidUrl
opUrl.url_for(
'@invalidUrl',
true,
).done(

function(url) {
'success': function (url) {
console.log(url); }
).fail(
},
'error':
function(xhr, textStatus, errorThrown) { console.log(xhr, textStatus, errorThrown); }
}
);

// -> xhr object, status, error

</code>
</pre>

Back