Populate 正在参加 2020 年度 OSC 中国开源项目评选,请投票支持!
Populate 在 2020 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
投票让它出道
已投票
授权协议 未知
开发语言
操作系统 未知
软件类型 开源软件
开发厂商
地区 不详
提 交 者 不详
适用人群 未知
收录时间 2008-09-19

软件简介

Populate a form or an element’s child elements using a JSON object.

This plugin supports full PHP naming and deep data structures, as well as checkbox arrays and other non-standard UI controls. The plugin can be used as part of your AJAX toolkit, or for separating server-side code from HTML by populating a form after the page has loaded eg:

$('form').populate({'text':'text', 'radio':1})

and not inline as the page is processed, such as:

<input type="text" name="text" id="text" value="<?php echo $text; ?>" />
<input type="radio" name="radio" id="radio-1" checked="<?php echo $val == 1; ?>" />
<input type="radio" name="radio" id="radio-2" checked="<?php echo $val == 2; ?>" />

Non-form elements

You can also populate non-form controls such as <div>s, by specifiying the id and an identifying attribute (defaults to id):

$('div').populate({'text-1':'text', 'text-2':'More text'})

This can be useful when you want to show the results of a database call, but don't want the text to be editable.

Usage

Just include the PHP JSON class, PHP helper function and of course Populate at the top of your page, and a PHP snippet such as this the bottom:

<?php populate('form', $data); ?/>

Which will output something meaningful like this:

$('form').populate({'text':'text', 'radio':1})

Live Demo

Finally!

I've now FINALLY put up a full set of instructions and a working demo, with examples of:

  • Populating a simple form, using string variable types for textfields, radiobuttons, dropdowns and checkboxes
  • Populating a complex form, using array variable types for checkbox arrays and multi-list boxes
  • Populating a hierarchical form, using hierarchical JSON data

View the jQuery Populate Demo here.

Download

JavaScript

PHP

展开阅读全文

评论 (0)

加载中
更多评论
暂无内容
发表了博客
2016/05/23 10:46

mongoose populate

mongoose populate用于对外键(objectid)字段的扩展,省去前段二次查询数据库的麻烦。 参考:http://mongoosejs.com/docs/populate.html 有2个特殊的用法: 1. 对objectid数组的populate,这个和单个objectid的populate一样; 2. Populating across multiple levels,即对objectid 下的objectid对象的populate User. fi...

0
0
发表了博客
04/06 08:39

[转] mongoose的populate

MongoDB是文档型数据库,所以它没有关系型数据库joins 特性。但是mongoose也有自己的方法来解决两个表之间的关联问题,Mongoose就是通过populate来解决这个问题的。接下来分享一下populate的方法。 populate的用法一 创建两个model var personSchema = Schema({ _id : Number, name : String, age :...

0
0
发表了博客
2016/07/12 13:31

BeanUtils.populate

BeanUtils.populate

0
0
发表了博客
2013/04/26 08:38

zz - How to use DesignData to populate controls...

How to use DesignData to populate controls with design time data in Silverlight and WPF Tweet Posted on August 6th, 2010 In this post I’ll be showing how you can use DesignData to populate controls when you’re designing Silverlight or WPF applications in Expression Blend or Visual Studio. The ...

0
0
2014/06/24 16:04

mongoose 使用populate 需要注意的问题

So far we've created two Models. Our Person model has it's stories field set to an array of ObjectIds. The refoption is what tells Mongoose which model to use during population, in our case the Story model. All _ids we store here must be document _ids from the Story model. We also declared the St...

0
2
发表了博客
2019/04/01 11:23

nodejs mongoose populate 多层模型

参考地址:http://ronaldroe.com/populating-multiple-fields-and-levels-with-mongoose/ 文字版本 Mongoose, the popular MongoDB library for NodeJS is incredibly robust and relatively easy to pick up. Its documentation, however leaves a little to be desired. To attain functionality similar to join f...

0
0
发表了博客
2019/04/02 14:42

UiPath - issue - "Newtonsoft.Json.JsonSerializationException: Cannot create and populate lis...

【问题描述】 用 UiPath (2019.3.0 Community Edition) 编写了一个非常简单的Tool,但是运行的时候出现了异常,下图是 Designer panel 的 workflow 和 异常截图 以下是详细的报错信息: 19.3.0+Branch.master.Sha.5fdb43627d7d3c011018bb545ddf9470210d44a9 Cannot create and populate list type System.Collectio...

0
0
发表了博客
05/03 13:40

【PHP】always_populate_raw_post_data = -1报错问题

<br /> <b>Deprecated</b>: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in ph......

0
0
发表了博客
2019/07/24 11:52

使用Django框架遇到RuntimeError: populate() isn't reentrant错误

在执行数据库迁移的时候报出错误RuntimeError: populate() isn't reentrant,之前也出过这个错误,但是忘记记录了,这次又出现了。百度搜好好多,都没解决我的问题,这里做个踩坑记录。 背景:项目有多个app,现在新需求增加了一个app,并编写了该app的utils文件 在执行python manage.py makemigrations后报出如下异常 ...

0
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
05/20 14:07

云计算时代,容器底层 cgroup 的代码实现分析

作者:姜亚华(@二如公子 ),《精通 Linux 内核——智能设备开发核心技术》的作者,一直从事与 Linux 内核和 Linux 编程相关的工作,研究内核代码十多年,对多数模块的细节如数家珍。曾负责华为手机 Touch、Sensor 的驱动和软件优化(包括 Mate、荣耀等系列),以及 Intel 安卓平台 Camera 和 Sensor 的驱动开发(包括 ...

5
46
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部