### Define JFinal Template Layout and Include Partial
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/sysOrg/addOrgUser.html
This snippet demonstrates how to structure a JFinal template. It starts by applying a predefined layout using `#@layout()`, defines a 'main' content block using `#define main()`, and then includes another HTML fragment or template file, `_form_table.html`, within that main block using `#include()`. This pattern is common for building reusable UI components and ensuring consistent page structures across an application.
```JFinal Template
#@layout() #define main()
#include("\_form\_table.html")
#end
```
--------------------------------
### JFinal Controller with BaseController for CRUD
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/README.md
Illustrates a JFinal controller extending `BaseController` to inherit common functionalities. It demonstrates `index()` for view rendering and `list()` for handling paginated data queries, including parameter retrieval (`getPara`, `getParaToInt`) and JSON response rendering (`renderJson`).
```Java
@ControllerBind(path="/portal/core/sysUser")
public class SysUserController extends BaseController {
@Inject
SysUserService service;
public void index() {
setAttr("orgList", service.queryOrgIdAndNameRecord());
render("index.html");
}
public void list() {
//条件查询
Record record = new Record();
record.set("userName", getPara("userName"));
record.set("orgId", getPara("orgId"));
record.set("sex", getPara("sex"));
renderJson(service.page(getParaToInt("pageNumber", 1), getParaToInt("pageSize", 10), record));
}
}
```
--------------------------------
### Example Undertow HTTP to HTTPS Redirection and Disabling
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/resources/undertow.txt
This snippet provides commented-out examples for configuring HTTP to HTTPS redirection and completely disabling HTTP when SSL is enabled. These settings are useful for enforcing secure connections and preventing unencrypted access.
```Properties
# ssl 开启时,http 请求是否重定向到 https
# undertow.http.toHttps=false
# ssl 开启时,是否关闭 http
# undertow.http.disable=false
```
--------------------------------
### Configure and Render ECharts Bar, Line, and Pie Charts
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/echart/index.html
This snippet initializes an ECharts configuration object and demonstrates how to set properties for bar, line, and pie charts. It includes defining chart titles, legends, axis data, series data, and then rendering each chart type using a custom 'echart' utility. It also shows an example of fetching data for charts.
```JavaScript
var _path="#(path)";
//变量配置
var config=echart.config;
console.log(config);
//柱状图
config.title="ECharts 入门示例";
config.title_x="center";
config.subtitle="测试";
config.legend=['销量'];
config.legend_x="left";
//config.xName="类型";
config.xAxis=["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"];
//config.yName="数量";
config.seriesName="销量";
config.seriesData=[5, 20, 36, 10, 10, 20];
config.divId="bar";
echart.bar(config);
//折线图
config.legend=['库存'];
config.seriesName="库存";
config.seriesData=[10,30,50,60,70,100];
config.divId="line";
echart.line(config);
//饼图
config.legend=["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"];
config.Name='库存';
config.seriesPieData=[{value:10,name:'衬衫'},{value:10,name:'羊毛衫'},{value:10,name:'雪纺衫'}, {value:10,name:'裤子'},{value:10,name:'高跟鞋'},{value:10,name:'袜子'}];
config.divId="pie";
config.tooltipText="件";
echart.pie(config);
//部门人数 统计
echart.getData("#(path)/portal/echart/queryData",null);
```
--------------------------------
### Basic CSS for Full-Height Preview Container
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/static/libs/ueditor/dialogs/preview/preview.html
This CSS snippet defines styles for `html`, `body`, and a `#preview` element to ensure they occupy 100% of the viewport height and width, removing default padding and margins. It also sets a default font family and size for elements within `#preview`.
```CSS
html,body{ height:100%; width:100%; padding:0; margin:0; } #preview{ width:100%; height:100%; padding:0; margin:0; } #preview \*{font-family:sans-serif;font-size:16px;}
```
--------------------------------
### LayUI Data Table Initialization with Custom Actions and Templates
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/README.md
Provides JavaScript code for initializing a LayUI data table, including configuration for pagination, custom dialog functions (`userRole`), and URLs for common CRUD operations. It defines table columns and integrates HTML script templates (`#sexStr`, `#numToStr`) for dynamic data rendering and interactive elements like switches.
```JavaScript
```
--------------------------------
### JavaScript for Dynamic Content Preview and Cleanup
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/static/libs/ueditor/dialogs/preview/preview.html
This JavaScript code handles the dynamic loading of content into the `#preview` element from an `editor` instance. It then uses a `uParse` utility to process the content, likely for rendering rich text or charts. Finally, it includes a cleanup function triggered when a dialog is cancelled, clearing the preview area.
```JavaScript
document.getElementById('preview').innerHTML = editor.getContent(); uParse('#preview',{ rootPath : '../../', chartContainerHeight:500 }) dialog.oncancel = function(){ document.getElementById('preview').innerHTML = ''; }
```
--------------------------------
### JFinal Template Layout and Include Directive
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/sysOrg/add.html
This snippet demonstrates the fundamental structure of a JFinal template. It defines a layout, a main content section, and includes a partial template file named '_form.html'. This pattern is common for building modular web pages.
```JFinal Template
#@layout() #define main()
#include("_form.html")
#end
```
--------------------------------
### JFinal Template Main Layout and Include
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/sysUser/my/index.html
This snippet demonstrates defining a main content block using `#define main()` within a layout template (`#@layoutT`) and including a partial HTML file (`_form.html`) using `#include()` in a JFinal application. It structures the page by embedding content into a predefined layout.
```JFinal Template
#@layoutT("我的信息") #define main()
#include("_form.html")
#end
```
--------------------------------
### JFinal Template for Data Dictionary Layout
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/dictionary/value/add.html
This snippet illustrates a basic JFinal template structure. It uses the `#@layoutT` directive to apply a layout named '数据字典' (Data Dictionary) to the page. The `#define main()` block defines the main content area, which then includes a partial HTML file named `_form.html` using the `#include` directive.
```JFinal Template
#@layoutT("数据字典") #define main()
#include("\_form.html")
#end
```
--------------------------------
### LayUI Form Layout with JFinal Custom Directives
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/README.md
Demonstrates creating a responsive form layout using LayUI's grid classes (`layui-row`, `layui-col-space1`) and JFinal's custom directives (`#@colStart`, `#@colEnd`). These directives simplify the creation of form fields with labels and input elements, ensuring proper styling and alignment.
```HTML
```
--------------------------------
### CodeMirror SQL Editor Initialization
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/common/templete/_layout.html
This JavaScript code initializes a CodeMirror instance for a textarea element with the ID 'ddlSql'. It configures the editor for SQL syntax highlighting, line numbering, bracket matching, and auto-sizing. Comments within the code provide guidance on how to programmatically get and set the editor's content.
```JavaScript
var ddlSqlId=document.getElementById("ddlSql"); if(ddlSqlId){ /** * 初始化 table sql 3 */ var ddlSql = CodeMirror.fromTextArea(ddlSqlId, { lineNumbers: true, matchBrackets: true, mode: "text/x-sql", lineWrapping:false, readOnly:false, foldGutter: true, gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"] }); ddlSql.setSize('auto','auto'); } // ddlSql.getValue();//取文本域值 // ddlSql.setValue(...);//给文本域赋值
```
--------------------------------
### JFinal Layout and Partial Inclusion Example
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/sysRole/add.html
This JFinal template snippet illustrates the use of `@layoutT` to specify a layout template, `#define main()` to define the primary content block, and `#include` to embed a reusable partial HTML file (`_form.html`). This pattern is common for building modular web pages in JFinal applications, promoting reusability and maintainability.
```JFinal Template
#@layoutT("角色管理") #define main()
#include("\_form.html")
#end
```
--------------------------------
### Configure Basic Layui Multi-Select Tags (selectM)
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/common/demo/select.html
This snippet illustrates the basic setup for the `selectM` component, designed for multi-select tag inputs. It initializes `selectM` with a target element (`#tag_ids1`), the `tagData` source, a maximum selection limit, and a basic form validation rule.
```JavaScript
//多选标签-基本配置
var tagIns1 = selectM({
//元素容器【必填】
elem: '#tag_ids1'
//候选数据【必填】
,data: tagData
,max:2
,width:400
//添加验证
,verify:'required'
});
```
--------------------------------
### JFinal Service with BaseService for Database Operations
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/README.md
Shows a JFinal service class extending `BaseService` to gain access to database persistence methods. The `getDao()` method is overridden to return the specific `Model`'s DAO instance, enabling data access layer operations.
```Java
public class SysUserService extends BaseService {
private SysUser dao = new SysUser().dao();
@Override
public Model> getDao(){
return dao;
}
}
```
--------------------------------
### Client-Side JavaScript for Login Form Handling
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/pub/login/login.html
This JavaScript code block handles initial setup for the login form. It declares variables for verification code and path, and dynamically changes the password input field type to address compatibility issues, specifically for browsers like 360 Browser that might interfere with remembered passwords.
```JavaScript
var vc="#(vc??)",_path="#(path)"; //解决360浏览器记住密码登录失败问题
$(function(){ changeType('text'); setTimeout("changeType('password')",100); });
function changeType(type){ $("#signup_password").attr("type",type); }
```
--------------------------------
### JavaScript for LayUI Data Grid Initialization
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/form/viewTemp/index.html
Initializes a LayUI data grid component named 'maingrid'. This JavaScript code configures the grid's title, data ID, and URLs for delete, update, and add operations. It defines the grid columns, including primary key, sequence number, type, name, order, and an operations column with a toolbar, specifying the data source URL and search form association.
```JavaScript
var object="sys_tree";
gridArgs.title='系统树';
gridArgs.dataId='id';
gridArgs.deleteUrl='#(path)/portal/form/business/delete?object='+object+'&primaryKey='+gridArgs.dataId;
gridArgs.updateUrl='#(path)/portal/form/business/edit?viewCode=view_update&id=';
gridArgs.addUrl='#(path)/portal/form/business/add?viewCode=view_add';
gridArgs.gridDivId ='maingrid';
initGrid({id : 'maingrid' ,elem : '#maingrid' ,cellMinWidth: 80 ,cols : [ [ {title: '主键',field : 'id',width : 35,checkbox : true}, {title:'序号',type:'numbers',width:35}, {title: '分类', field: 'type'}, {title: '名称', field: 'name' }, {title: '排序', field: 'order_no'}, {title: '操作',fixed:'right',width : 180,align : 'left',toolbar : '#bar_maingrid'} ] ] ,url:"#(path)/portal/form/business/list" ,where:{"object":object,"primaryKey":gridArgs.dataId} ,searchForm : 'searchForm' });
```
--------------------------------
### Simulate Asynchronous Data Loading for UI Components
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/common/demo/layuiTableEdit.html
This JavaScript snippet demonstrates how to prepare static data for UI components and simulate asynchronous loading using `setTimeout`. It conditionally returns different datasets (`result` or `result1`) based on a `cascadeSelectField` value, then calls a `tableEdit.callbackFn` to update the UI. This pattern is useful for testing asynchronous data flows or for initial data setup.
```javascript
var result = { data:[{name:1,value:'语文'},{name:2,value:'数学'},{name:3,value:'英语'},{name:4,value:'物理'},{name:5,value:'化学'}], enabled:false //单选 true为多选 };
var result1 = { data:[{name:6,value:'政治'},{name:7,value:'地理'},{name:8,value:'历史'},{name:9,value:'生物'},{name:10,value:'音乐'}], enabled:false //单选 true为多选 };
//这里用定时器来模拟异步操作,同步操作直接return即可。
setTimeout(function () {
if(cascadeSelectField === 'rqjl'){
tableEdit.callbackFn("async(tableEvent)",result1);
}else {
tableEdit.callbackFn("async(tableEvent)",result);
}
},500);
```
--------------------------------
### Manipulate UEditor Content (HTML, Text)
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/static/libs/ueditor/index.html
Functions for inserting HTML, retrieving all HTML content, getting plain text content, and setting editor content. `insertHtml` takes user input to insert HTML, `getAllHtml` retrieves the full HTML, `getContent` gets the editor's content, `getPlainTxt` gets formatted plain text, and `setContent` allows setting new content, optionally appending it.
```JavaScript
function insertHtml() {
var value = prompt('插入html代码', '');
UE.getEditor('editor').execCommand('insertHtml', value)
}
function getAllHtml() {
alert(UE.getEditor('editor').getAllHtml())
}
function getContent() {
var arr = [];
arr.push("使用editor.getContent()方法可以获得编辑器的内容");
arr.push("内容为:");
arr.push(UE.getEditor('editor').getContent());
alert(arr.join("\n"));
}
function getPlainTxt() {
var arr = [];
arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
arr.push("内容为:");
arr.push(UE.getEditor('editor').getPlainTxt());
alert(arr.join('\n'))
}
function setContent(isAppendTo) {
var arr = [];
arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
alert(arr.join("\n"));
}
```
--------------------------------
### Configure Basic Undertow Server and GZIP Compression
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/resources/undertow.txt
This snippet configures fundamental Undertow server settings such as development mode, host, port, and session timeout. It also enables and fine-tunes GZIP compression by setting the compression level and minimum content length for triggering compression.
```Properties
undertow.devMode=true
undertow.host=0.0.0.0
undertow.port=80
# 开启 gzip 压缩
undertow.gzip.enable=true
# 配置压缩级别,默认值 -1。 可配置 1 到 9。 1 拥有最快压缩速度,9 拥有最高压缩率
undertow.gzip.level=-1
# 触发压缩的最小内容长度
undertow.gzip.minLength=1024
#session有效期:60分钟
undertow.session.timeout=3600
```
--------------------------------
### Manage UEditor State and Selection
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/static/libs/ueditor/index.html
Functions to enable/disable the editor, retrieve selected text, check if the editor has content, and set focus. `setDisabled` disables the editor, `setEnabled` re-enables it, `getText` gets the currently selected text, `getContentTxt` gets pure plain text, `hasContent` checks for content presence, and `setFocus` brings focus to the editor.
```JavaScript
function setDisabled() {
UE.getEditor('editor').setDisabled('fullscreen');
disableBtn("enable");
}
function setEnabled() {
UE.getEditor('editor').setEnabled();
enableBtn();
}
function getText() {
//当你点击按钮时编辑区域已经失去了焦点,如果直接用getText将不会得到内容,所以要在选回来,然后取得内容
var range = UE.getEditor('editor').selection.getRange();
range.select();
var txt = UE.getEditor('editor').selection.getText();
alert(txt)
}
function getContentTxt() {
var arr = [];
arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
arr.push("编辑器的纯文本内容为:");
arr.push(UE.getEditor('editor').getContentTxt());
alert(arr.join("\n"));
}
function hasContent() {
var arr = [];
arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
arr.push("判断结果为:");
arr.push(UE.getEditor('editor').hasContents());
alert(arr.join("\n"));
}
function setFocus() {
UE.getEditor('editor').focus();
}
```
--------------------------------
### Generate PKCS12 Keystore for SSL with Keytool
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/resources/undertow.txt
These shell commands demonstrate how to generate a new RSA key pair and then convert the resulting JKS keystore to a PKCS12 format. This is a common step for preparing SSL certificates for server deployment, especially when migrating or setting up new environments.
```Shell
keytool -genkeypair -validity 3650 -alias club -keyalg RSA -keystore club.jks
keytool -importkeystore -srckeystore club.jks -destkeystore club.pfx -deststoretype PKCS12
```
--------------------------------
### JavaScript Initialization and Dynamic Height Adjustment
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/sysUser/userRole.html
Initializes JavaScript functions on document ready, including querying role tree and user roles, and dynamically adjusts the height of UI elements (#maingrid, .func_tree) based on window height for responsive layout.
```JavaScript
var rightOption,rightNodes,treeNodes;
var userCode="#(userCode)";
$(function(){
queryRoleTree();
setHeight();
setTimeout(function(){
queryUserRole();
},150);
});
function setHeight(){
var height=$(window).height()-5;
$("#maingrid").css("height",height);
$(".func_tree").css("height",height-32);
}
```
--------------------------------
### Initialize UEditor with Custom Configuration
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/common/templete/ueditor.html
Initializes the UEditor instance on an HTML element with the ID 'container'. This example demonstrates how to pass an object of configuration parameters to `UE.getEditor()`, allowing specific settings like `initialFrameHeight` and `wordCount` to be overridden from `ueditor.config.js`.
```JavaScript
var ue = UE.getEditor('container', {
initialFrameHeight:300
// , initialFrameWidth:796
,wordCount:false
});
```
--------------------------------
### Basic CSS Styling for HTML Elements
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/static/libs/ueditor/dialogs/snapscreen/snapscreen.html
This CSS snippet defines foundational styles for HTML and body elements, sets font sizes, manages overflow, and provides specific styling for headings (h2), content containers, definition lists (dt, dd), links (a), and input fields. It ensures a consistent look and feel for basic UI components.
```CSS
html,body { font-size: 12px; width:100%; height:100%; overflow: hidden; margin:0px; padding:0px; }
h2 { font-size: 16px; margin: 20px auto;}
.content{ padding:5px 15px 0 15px; height:100%; }
dt,dd { margin-left: 0; padding-left: 0;}
dt a { display: block; height: 30px; line-height: 30px; width: 55px; background: #EFEFEF; border: 1px solid #CCC; padding: 0 10px; text-decoration: none; }
dt a:hover{ background: #e0e0e0; border-color: #999 }
dt a:active{ background: #ccc; border-color: #999; color: #666; }
dd { line-height:20px;margin-top: 10px;}
span{ padding-right:4px;}
input{width:210px;height:21px;background: #FFF;border:1px solid #d7d7d7;padding: 0px; margin: 0px; }
```
--------------------------------
### Define JavaScript Variable using JFinal Enjoy Template
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/form/business/add.html
This snippet shows how to define a JavaScript variable `saveUrl` within a JFinal Enjoy `#define layuiFunc()` block. The URL path is dynamically constructed using a JFinal template variable `#(path)`.
```JFinal Enjoy
#define layuiFunc() var saveUrl="#(path)/portal/form/business/save"; #end
```
--------------------------------
### JFinal Template Variable Assignment
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/portal/core/sysOrg/_form_table.html
Shows how to set a variable's value within a JFinal template using the `#set` directive. This example assigns a boolean value `true` to the variable `req`, which might be used for conditional rendering or form validation.
```JFinal Template
#set(req=true)
```
--------------------------------
### Configure Undertow Server for SSL/HTTPS
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/resources/undertow.txt
This snippet details how to enable SSL for the Undertow server, specifying the listening port (e.g., 443 for production), the keystore type (PKCS12 recommended), the path to the keystore file, and its password. These settings are crucial for securing communication via HTTPS.
```Properties
undertow.ssl.enable=false
# ssl 监听端口号,部署环境设置为 443
undertow.ssl.port=443
# 密钥库类型,建议使用 PKCS12
undertow.ssl.keyStoreType=PKCS12
# 密钥库文件
undertow.ssl.keyStore=club.pfx
# 密钥库密码
undertow.ssl.keyStorePassword=111111
```
--------------------------------
### JavaScript Flash Image Uploader Initialization Options
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/static/libs/ueditor/dialogs/wordimage/wordimage.html
Defines a comprehensive set of configuration parameters for the Flash-based image uploader component. These options specify the container ID, server URL, allowed file types, dimensions for the Flash interface and image previews, field names for uploaded data, and various limits for file size and quantity, including compression settings.
```javascript
var flashOptions = {
container:"flashContainer", //flash容器id
url:urlWidthParams, // 上传处理页面的url地址
ext:editor.queryCommandValue('serverParam') || {}, //可向服务器提交的自定义参数列表
fileType:'{"description":"'+lang.fileType+'", "extension":"' + extension + '"}', //上传文件格式限制
flashUrl:'imageUploader.swf', //上传用的flash组件地址
width:600, //flash的宽度
height:272, //flash的高度
gridWidth:120, // 每一个预览图片所占的宽度
gridHeight:120, // 每一个预览图片所占的高度
picWidth:100, // 单张预览图片的宽度
picHeight:100, // 单张预览图片的高度
uploadDataFieldName: optImageFieldName, // POST请求中图片数据的key
picDescFieldName:'pictitle', // POST请求中图片描述的key
maxSize: maxSize, // 文件的最大体积,单位M
compressSize:1, // 上传前如果图片体积超过该值,会先压缩,单位M
maxNum:32, // 单次最大可上传多少个文件
compressSide: 0, //等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度
compressLength: optImageCompressBorder //能接受的最大边长,超过该值Flash会自动等比压缩
};
```
--------------------------------
### JFinal Template Directive for UEditor Inclusion
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/common/templete/ueditor.html
Defines a JFinal template directive to include and initialize the UEditor rich text editor. This directive allows passing custom initialization parameters to override default configurations, which is useful for different UEditor setups within the same project.
```JFinal Template
#define ueditor()
```
--------------------------------
### Layui JavaScript Initialization and Dynamic Menu Handling
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/index.html
This JavaScript code leverages the Layui framework to manage UI interactions. It sets up event listeners for user profile and password change dialogs, and dynamically opens multi-level navigation tabs based on the `navData` structure, ensuring a responsive user experience.
```JavaScript
layui.use('layer', function() { var $ = layui.jquery, layer = layui.layer; $('#userInfor').on('click', function() { openDialog('个人信息','#(path)/portal/core/sysUser/my?id='+userId,false,800,500,null); }); $('#passwd').on('click', function () { openDialog('修改密码','#(path)/portal/core/sysUser/myPassword?id='+userId,false,450,300,null); }); for(var i=0;i编辑 删除
```
--------------------------------
### JFinal Template Global Variable Initialization
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/index.html
This snippet initializes global JavaScript variables using JFinal's templating engine. It sets up `navData` for navigation, `userId` for user identification, and `_path` for base URL paths, which are crucial for dynamic content loading.
```JFinal Template
#(projectName) #@header() var navData=#(funcList); var userId="#(vs.code)"; var _path="#(path)";
```
--------------------------------
### Layui UI Initialization and AJAX Form Submission
Source: https://github.com/qinhaisenliin/jfinal-layui/blob/master/src/main/webapp/WEB-INF/views/common/templete/_layout.html
This JavaScript block initializes key Layui modules such as table, form, jQuery, laydate, and element. It configures date and datetime pickers for input fields and sets up a form submission listener. The listener uses jQuery's `ajaxSubmit` to asynchronously send form data, handling success and warning responses from the server.
```JavaScript
layui.use([ 'table', 'form', 'jquery','laydate','element'], function() { var table = layui.table; var form = layui.form; var layer = layui.layer; var $ = layui.$; var laydate = layui.laydate; var element = layui.element; //执行一个laydate日期选择控件实例 lay('.layui-date').each(function(){ laydate.render({ elem: this ,trigger:'click' }); }); //执行一个laydate日期时间控件实例 lay('.layui-date-time').each(function(){ laydate.render({ elem: this ,type:'datetime' ,trigger:'click' }); }); //layui相关语法函数 #@layuiFunc?() //表单提交监听 form.on('submit(saveForm)', function(data) { $(this).ajaxSubmit({ type : 'post', url : saveUrl, success : function(data) { if (data.state == 'ok') { parent.success(data.msg); $('#closeWinBtn').click(); } else { warn(data.msg); $('#submitBtn').attr("disabled",false); } } }); }); form.render(); });
```