顯示具有 jQuery 標籤的文章。 顯示所有文章
顯示具有 jQuery 標籤的文章。 顯示所有文章

2014年10月16日 星期四

jquery 過濾 字串 空白鍵

jQuery.trim()

jquery 過濾 字串 空白鍵 

Example: 

$.trim("         hello, how are you?       ");

Result:

"hello, how are you?"

CKEditor (jQuery Plugin) 文字編輯工具列

文字編輯工具
原本以為做文字編輯器很難,沒想到這麼簡單!
首先下載 CKEditor.js,你可以客製化喜歡的外觀,
還可以選擇 簡易版、標準版或完整版,
選完後下載下來,匯入的時候注意連結位置。

匯入CKEditor.js之後 View 的處理很簡單,
幫 <textarea> 加上一個 class="ckeditor",
大功告成。

=========================================

includ:
<script src="yourfolder/ckeditor.js" type="text/javascript"></script>

View:
<textarea class='ckeditor' id='' rows='' name=""></textarea>

萬一你需要自己呼叫 CKEditor你可以參考下列程式碼!
call CKEditor method:
CKEDITOR.replace("textarea#id");



2013年10月31日 星期四

CSS Hover IE 無法正常顯示

用jQuery解決IE CSS Hover無法正常顯示的方法:

解法一:

if( window.BrowserDetect.browser == "Explorer" )
{

        $('.Button').unbind('mouseenter mouseleave').bind('mouseenter mouseleave', function() {
                  $(this).toggleClass('Button-hover');
        });


}


解法二:

$(".Button").hover(function() {

         $(this).css("background-color","#FFE100");
},function(){
         $(this).css('background-color','#C4C4C4');
});






2013年10月30日 星期三

jsTree 功能, Demo 程式碼測試

jsTree Home: http://www.jstree.com/


// Judge the tree folder is opened or collapsed
// 1) select the tree container using jQuery and call '.jstree("is_open","#tree_list_ID")'
$("#xml_o").jstree("is_open" , "#1");



// To toggle the tree folder open or collapse
// 1) select the tree container using jQuery and call '.jstree("toggle_node","#tree_list_ID")'
$("#xml_o").jstree("toggle_node","#html_1");



// To select the tree list
// 1) select the tree container using jQuery and call '.jstree("select_node","#tree_list_ID")'
$("#xml_o").jstree("select_node","#1" )


// To deselect the tree list
// 1) select the tree container using jQuery and call '.jstree("deselect_node","#tree_list_ID")'
$("#xml_o").jstree("deselect_node","#1" );



// To rename the tree list
// 1) select the tree list first
// 2) select the tree container using jQuery and call '.jstree("rename")'
$("#xml_o").jstree("rename");



// To delete the tree list
// 1) select the tree list first
// 2) select the tree container using jQuery and call .jstree("remove")
$("#xml_o").jstree("remove");


// To refresh the tree
// 1) select the tree container using jQuery and call .jstree("refresh")
$("#xml_o").jstree("refresh" );


// To collapse all tree
// 1) select the tree container using jQuery and call .jstree("close_all")
$("#xml_s_matrix_1").jstree("close_all");


// To open all tree
// 1) select the tree container using jQuery and call .jstree("open_all")
$("#xml_s_matrix_1").jstree("open_all");

// To refresh node of the tree
// 1) select the tree container using jQuery and call .jstree("refresh","#node")
$("#xml_s_matrix_1").jstree("refresh","#8");

// To get *json
// 1) select the tree container using jQuery and call .jstree("get_json")
$("#xml_o").jstree("get_json" );

// This function returns an array of tree nodes converted back to JSON.
// 1) select the tree container using jQuery and call .jstree("get_json","node")
$("#xml_s_matrix_1").jstree("get_json","#1");

//Returns the title of a node.
// 1) select the tree container using jQuery and call .jstree("set_text","node")
$("#xml_s_matrix_1").jstree("get_text","#8"); get name


//Sets the title of a node.
// 1) select the tree container using jQuery and call .jstree("set_text","node", "text")
$("#xml_s_matrix_1").jstree("set_text","#8","123");

//Creates the DOM structure necessary for a new node.
$("#xml_s_matrix_1").jstree("create_node", "#8", "1234");
parent_id position




(*) JSON: JavaScript Object Notation.
JSON is syntax for storing and exchanging text information. Much like XML.

JSON is smaller than XML, and faster and easier to parse.