运行中主要文件,仅限参考
HTML:
{$CONF['shopTitle']['fieldValue']}后台管理中心var url="{:U('News/typeTree')}";
$(function () {
bindDB({ajaxurl:"{:U('News/typeTree')}"});
KindEditor.ready(function(K) {
editor1 = K.create('textarea[name="articleContent"]', {
height:'350px',
allowFileManager : false,
allowImageUpload : true,
items:[
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
'anchor', 'link', 'unlink', '|', 'about'
],
afterBlur: function(){ this.sync(); }
});
});
$.formValidator.initConfig({
theme:'Default',mode:'AutoTip',formID:"myform",debug:true,submitOnce:true,onSuccess:function(){
edit();
return false;
},onError:function(msg){
}});
$("#articleTitle").formValidator({onFocus:"请输入文章标题"}).inputValidator({min:1,max:100,onError:"请输入100字以内文章标题"});
$("#catId").formValidator({onFocus:"请选择文章分类"}).inputValidator({min:1,onError: "请选择文章分类"});
$("#articleKey").formValidator({onFocus:"请输入关键字"}).inputValidator({min:1,max:80,onError:"请输入关键字"});
});
文章标题*: | |
---|---|
分类*: | 请选择 {$vo.catName} |
是否显示*: | checked />显示 checked />隐藏 |
关键字*: | |
内容*: | {$list.newsContent} |
js:
$(document).ready(function(){
function bindDB(options){
//alert(options);
var opt = options || {},
$bindDB = $(".bindDB"),
len = 0,
nameText = "";
if(!$bindDB[0]){$.error("对象不存在!");return false;};
len = $bindDB.length;
$(".bindDB").live("change",function() {
if(this.name && this.tagName == "SELECT")
{
var that = $(this);
//alert(that);
that.nextAll(".bindDB").remove();
len=$(".bindDB").length;
//alert(len);
if(/_/g.test(this.name)){
nameText = this.name.split("_")[0]+"_";
this.name = nameText+(len-1);
}else{
nameText = this.name+"_";
this.name = nameText+(len-1);
};
$.ajax({
url:url,
dataType:"json",
type:'post',
data:{id:$(this).val()},
timeout:5000,
error: function(error){
alert("网络超时!");
},
success: function(data){
//console.
//alert(data);
//var data = eval("("+data+")");
console.log(data);
var option = "";
$.each(data,function(k,v){
option+= ""+v.catName+""
});
that.after(""+option+"");
}
});
}
});
};
//bindDB();
window.bindDB = bindDB;
})
thinkphp:
public function typeTree(){
//获取商品分类信息
$catId=I('post.id');
$this->ajaxReturn($catId);exit;
$m = M('goods_cats');
$rs = $m->where('parentId='.$catId)->select();
echo json_encode($rs);
}