Skip to content

Instantly share code, notes, and snippets.

@kanonji

kanonji/ex_html.php

Created Jan 27, 2011
Embed
What would you like to do?
<?php
/**
* Extended HtmlHelper
* @author kanonji
*/
class ExHtmlHelper extends HtmlHelper {
/**
* $.webroot() for jQuery
*
* To get webroot path when using jQuery.
* This is a little closer to Helper::webroot().
*
* $.getScript($.webroot('js/jquery.example-plugin.js'), function(){//callback});
*
* @param array $options
*/
public function setWebroot($options = array()){
$url = $this->url('/');
return $this->scriptBlock("
$.extend({
webroot: function(path) {
if(! path)
path = '';
return '{$url}'+path;
}
});"
, $options);
}
}
@nojimage

This comment has been minimized.

Copy link

@nojimage nojimage commented Jan 27, 2011

18行目で$this->url();と引数なしで呼び出してますが、これだと呼び出し時のパスになるのでwebrootからの絶対パス指定ではなく相対パス指定みたいになりませんか?

@kanonji

This comment has been minimized.

Copy link
Owner Author

@kanonji kanonji commented Jan 28, 2011

コメントどうもです。
おもいっきりミスってますね。作ったのに結局indexページでしか使わなかったので気がついてませんでした・・・

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.