我在更新某些信息方面遇到了一些麻烦:
我有一个数组,其中每一行都是一个表单。这里是玉石的样子:
each info in infos
form(method="post")
input(type='hidden', name='action', value='save')
td
input(value='#{info.name.full}' disabled).form-control
td
input(value='#{info.field}' disabled).form-control
td
input(value='#{info.field1}' disabled).form-control
td
input(value='#{info.field2}' disabled).form-control
td
input(value='#{info.field3}' disabled).form-control
td
input(value='#{info.field4}' disabled).form-control
td
input(value='#{info.field5}' disabled).form-control
td
input(value='#{info.field6}' disabled).form-control
td
input(value='#{info.field7}' disabled).form-control
td
select(name='status').form-control
option(value="")=(require)
option(value="bla")="Bla"
option(value="blabla")="Bla bla"
option(value="blablabla")="Bla bla bla"
option(value="blablablabla")="Bla bla bla bla"
td
button(type='submit').btn.btn-primary Save
我希望能够保存每一行,但在点击&#34时我无法检索到ID。保存"。
我的JavaScript看起来像这样:
view.on('post', { action: 'save' }, function (next) {
var application = new Info.model();
var updater = application.getUpdateHandler(req);
updater.process(req.body, {
flashErrors: true
}, function (err) {
if (err) {
locals.validationErrors = err.errors;
} else {
locals.updateSubmitted = true;
}
next();
});
});
但我想我不明白updateHandler是如何工作的。
有没有人知道如何通过检索ID来保存行?
答案 0 :(得分:0)
为了解决这个问题,我添加了
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:orientation="horizontal">
<ImageView
android:id="@+id/frag_home_iv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@android:drawable/sym_def_app_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.26"
android:background="@color/colorAccent"
android:orientation="vertical"
android:padding="@dimen/padding_5dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="@dimen/padding_3dp"
android:weightSum="1">
<ImageView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.33"
android:padding="@dimen/margin_5dp"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.67"
android:text="asdsdgvsfdagsmdknsdjkcjkcbvuhsdjkfnh sjvnfslbvhsdfglsfvbfvufvgl,fgklcm,.vngkg.f,gm kjfbkjvn,dfmgkjhfgasfgkksfgmkdjfbndfbjkdnh,.dghlkgd"
android:textColor="@color/BlackColor" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="0.74"
android:orientation="vertical"
android:weightSum="1"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_8dp"
android:layout_weight="1"
android:background="@color/HomeListItem2"
android:orientation="horizontal"
android:padding="@dimen/padding_3dp"
android:weightSum="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.7"
android:text="sanf,cbjkdbvjdkfnashdfkjnsjabsjdmfnvshbgvbvvbuhfbvgkdfbuhvdfgjkfbghsjkvkcbfgmbfhuvgbfgvfsjghsjvknfvfngvbfuygbvjkakhsdjhgvhfjnuyvhjfdnjgnifhg"
android:textColor="@color/WhiteColor" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_8dp"
android:layout_weight="1"
android:background="@color/HomeListItem3"
android:orientation="horizontal"
android:padding="@dimen/padding_3dp"
android:weightSum="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.7"
android:padding="@dimen/padding_10dp"
android:text="awofkldjvugifklgmfhklmfgtnemylktmfedghquafrgmketo"
android:textColor="@color/WhiteColor" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_8dp"
android:layout_weight="1"
android:background="@color/HomeListItem4"
android:orientation="horizontal"
android:padding="@dimen/padding_3dp"
android:weightSum="1">
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.3"
android:padding="@dimen/margin_5dp"
android:src="@android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.7"
android:text="flkghoijhfnigksngaugjknnguhfbjvncuyvgijfgyhfnvjfdnvjkayfgnkdfbvhjcvndfighfdmndfiuhvhnfidjghiudfhguifdhgiuhafgijhnfaiifjgnu8idfhbjkfndbguy"
android:textColor="@color/WhiteColor" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
在
之后input(type='hidden', name='id', value='#{info.id}')
然后我可以通过以下方式访问数据:
input(type='hidden', name='action', value='save')
我更新了我的桌子:
console.log(req.body.id);
console.log(req.body.item1);
希望这会对你们中的一些人有所帮助。