Home Web Front-end CSS Tutorial jQuery EasyUI Tutorial-Panel (Panel)

jQuery EasyUI Tutorial-Panel (Panel)

Mar 23, 2017 pm 05:30 PM
easyui jquery panel

<br/>
Copy after login

From now on, I will explain to you the first section of the jQuery EasyUI tutorial-Layout: jQuery-panel (panel) component. The usage of this component is almost the same as the components in the previous articles. , the case is also implemented by setting some panel properties, events and methods triggered by the operation panel. We can learn from these three points. <br/>

Use $.fn.panel.defaults to override the default value object.

Panels serve as containers for other content. This is the basis for building other components (such as layout, tabs, accordion, etc.). It also provides collapse, close, maximize, minimize and custom behaviors. Panels can be easily embedded anywhere on a web page.

jQuery EasyUI Tutorial-Panel (Panel)

Use case:

Creating a panel

In front-end development work, panels are created through two methods: tags and programs.

1. Create panel through tags

Creating through tags is easier. Add 'easyui-panel' class ID to

tag.

<p id=”p” class=”easyui-panel” title=”My Panel”
style=”width:500px;height:150px;padding:10px;background:#fafafa;”
data-options=”iconCls:’icon-save’,closable:true,
collapsible:true,minimizable:true,maximizable:true”>
<p>panel content.</p>
<p>panel content.</p>
</p>
Copy after login

2. Create the panel program

Let us create the toolbar in the upper right corner of the panel.

<p id=”p” style=”padding:10px;”>
<p>panel content.</p>
<p>panel content.</p>
</p>
$(‘#p’).panel({
width:500,
height:150,
title: ‘My Panel’,
tools: [{
iconCls:’icon-add’,
handler:function(){alert(‘new’)}
},{
iconCls:’icon-save’,
handler:function(){alert(‘save’)}
}]
});
Copy after login

Move panel

Call the 'move' method to move the panel to a new location.

$(‘#p’).panel(‘move’,{
left:100,
top:100
});
Copy after login

Read content

When the loading is successful, let us load the panel content through ajax and display some messages.

$(‘#p’).panel({
href:’content_url.php’,
onLoad:function(){
alert(‘loaded successfully’);
}
});
Copy after login

Attributes:

属性名属性值类型描述
idstring面板的ID属性。
titlestring在面板头部显示的标题文本。
iconClsstring设置一个16×16图标的CSS类ID显示在面板左上角。
widthnumber设置面板宽度。
heightnumber设置面板高度。
leftnumber设置面板距离左边的位置(即X轴位置)
topnumber设置面板距离顶部的位置(即Y轴位置)
clsstring添加一个CSS类ID到面板
headerClsstring添加一个CSS类ID到面板头部
bodyClsstring添加一个CSS类ID到面板正文部分
styleobject添加一个当前指定样式到面板。如下代码示例更改面板边框宽度:
<p class="easyui-panel" style="width:200px;height:100px"
        data-options="style:{borderWidth:2}">
</p>
Copy after login
fitboolean

当设置为true的时候面板大小将自适应父容器。下面的例子显示了一个面板;可以自动在父容器的最大范围内调整大小。

<p style="width:200px;height:100px;padding:5px">
<p class="easyui-panel" style="width:200px;height:100px"
data-options="fit:true,border:false">
Embedded Panel
</p>
</p>
Copy after login

<br/>

borderboolean定义是否显示面板边框。
doSizeboolean如果设置为true,在面板被创建的时候将重置大小和重新布局。
noheaderboolean如果设置为true,那么将不会创建面板标题
contentstring面板主体内容
collapsibleboolean定义是否显示可折叠按钮。
minimizableboolean定义是否显示最小化按钮。
maximizableboolean定义是否显示最大化按钮。
closableboolean定义是否显示关闭按钮。
toolsarray,selector自定义工具菜单,可用值:<br/>1) 数组,每个元素都包含’iconCls’和’handler’属性。<br/>2) 指向工具菜单的选择器。<br/>

面板工具菜单可以声明在已经存在的

标签上:

<p class="easyui-panel" style="width:300px;height:200px"
title="My Panel" data-options
="iconCls:&#39;icon-ok&#39;,tools:&#39;#tt&#39;">
</p>
<p id="tt">
<a href="#" class="icon-add" onclick
="javascript:alert(&#39;add&#39;)"></a>
<a href="#" class="icon-edit" onclick
="javascript:alert(&#39;edit&#39;)"></a>
</p>
Copy after login

面板工具菜单也可以通过数组定义:

<p class="easyui-panel" style="width:300px;height:200px"
title="My Panel" data-options="iconCls:&#39;icon-ok&#39;,tools:[
{
iconCls:&#39;icon-add&#39;,
handler:function(){alert(&#39;add&#39;)}
},{
iconCls:&#39;icon-edit&#39;,
handler:function(){alert(&#39;edit&#39;)}
}]">
</p>
Copy after login

<br/>

collapsedboolean定义是否在初始化的时候折叠面板。
minimizedboolean定义是否在初始化的时候最小化面板。
maximizedboolean定义是否在初始化的时候最大化面板。
closedboolean定义是否在初始化的时候关闭面板。
hrefstring从URL读取远程数据并且显示到面板。注意:内容将不会被载入,直到面板打开或扩大,在创建延迟加载面板时是非常有用的:
<p id="pp" class="easyui-panel" style
="width:300px;height:200px"
data-options="href=&#39;get_content.php&#39;,closed:true">
</p>
<a href="#" onclick
="javascript:$(&#39;#pp&#39;).panel(&#39;open&#39;)">Open</a>
Copy after login
cacheboolean如果为true,在超链接载入时缓存面板内容
loadingMessagestring在加载远程数据的时候在面板内显示一条消息
extractorfunction定义如何从ajax应答数据中提取内容,返回提取数据。
xtractor: function(data){
	var pattern = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
	var matches = pattern.exec(data);
	if (matches){
		return matches[1];	// 仅提取主体内容
	} else {
		return data;
	}
}
Copy after login
methodstring使用HTTP的哪一种方法读取内容页。可用值:’get’,’post’。(该属性自1.3.6版开始可用)
queryParamsobject在加载内容页的时候添加的请求参数。(该属性自1.3.6版开始可用)
loaderfunction定义了如何从远程服务器加载内容页,该函数接受以下参数:<br/>param:参数对象发送给远程服务器。<br/>success(data):在检索数据成功的时候调用的回调函数。<br/>error():在检索数据失败的时候调用的回调函数。<br/>(该属性自1.3.6版开始可用)

event:

事件名事件参数描述
onBeforeLoadnone在加载内容页之前触发,返回false将忽略该动作。(该事件自1.3.6版开始可用)
onLoadnone在加载远程数据时触发
onLoadErrornone在加载内容页发生错误时触发。(该事件自1.3.6版开始可用)
onBeforeOpennone在打开面板之前触发,返回false可以取消打开操作
onOpennone在打开面板之后触发
onBeforeClosenone在关闭面板之前触发,返回false可以取消关闭操作。下列的面板将不能关闭。
<p class="easyui-panel" style="width:300px;height:200px;"
title="My Panel" data-options
="onBeforeClose:function(){return false}">
 面板将不能关闭
</p>
Copy after login
onClosenone在面板关闭之后触发。
onBeforeDestroynone在面板销毁之前触发,返回false可以取消销毁操作
onDestroynone在面板销毁之后触发
onBeforeCollapsenone在面板折叠之前触发,返回false可以终止折叠操作。
onCollapsenone在面板折叠之后触发
onBeforeExpandnone在面板展开之前触发,返回false可以终止展开操作。
onExpandnone在面板展开之后触发
onResizewidth, height在面板改变大小之后触发。<br/>width:新的宽度。<br/>height: new height.
onMoveleft,topFires after the panel moves. <br/>left: New left margin position. <br/>top: New top margin position
onMaximizenoneTriggered after the window is maximized
onRestorenoneTriggered after the window is restored to its original size.
onMinimizenoneFires after the window is minimized.

method:

The above is the content of the jQuery EasyUI tutorial-Panel (Panel). For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Related articles:

easyui datagrid paging 4, easyUI-seven layouts (layout)

First introduction to general database Operation front-end easyui-datagrid, form (php), easyuidatagrid

A brief analysis of the tree usage guide in jQuery EasyUI

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

Summary of commonly used file operation functions in PHP Summary of commonly used file operation functions in PHP Apr 03, 2024 pm 02:52 PM

目录1:basename()2:copy()3:dirname()4:disk_free_space()5:disk_total_space()6:file_exists()7:file_get_contents()8:file_put_contents()9:filesize()10:filetype()11:glob()12:is_dir()13:is_writable()14:mkdir()15:move_uploaded_file()16:parse_ini_file()17:

See all articles
方法名方法参数描述
optionsnone返回属性对象。
panelnone返回面板对象。
headernone返回面板头对象。
bodynone返回面板主体对象。
setTitletitle设置面板头的标题文本。
openforceOpen在’forceOpen’参数设置为true的时候,打开面板时将跳过’onBeforeOpen’回调函数。
closeforceClose在’forceClose’参数设置为true的时候,关闭面板时将跳过’onBeforeClose’回调函数。
destroyforceDestroy在’forceDestroy’参数设置为true的时候,销毁面板时将跳过’onBeforeDestory’回调函数。
refreshhref刷新面板来装载远程数据。如果’href’属性有了新配置,它将重写旧的’href’属性。代码示例:
// 打开面板且刷新其内容。
$(&#39;#pp&#39;).panel(&#39;open&#39;).panel(&#39;refresh&#39;);
// 刷新一个新的URL内容
$(&#39;#pp&#39;).panel(&#39;open&#39;).panel(&#39;refresh&#39;,&#39;new_content.php&#39;);
Copy after login
resizeoptions设置面板大小和布局。参数对象包含下列属性:<br/>width:新的面板宽度。<br/>height:新的面板高度。<br/>left:新的面板左边距位置。<br/>top:新的面板上边距位置。代码示例:
$(&#39;#pp&#39;).panel(&#39;resize&#39;,{
	width: 600,
	height: 400
});
Copy after login

move options 移动面板到一个新位置。参数对象包含下列属性:
left:新的左边距位置。
top: New top margin position.
maximize options Maximize the panel to the container size.
minimize none Minimize the panel.
restore none Restore the maximized panel back to its original size and position.
collapse animate Collapse panel theme.
expand animate Expand the panel body.