按钮下拉列表项目类型=“提交”

时间:2018-01-12 13:43:07

标签: html css django

我正在开发一个django应用程序,并在我的页面中有一个表单。

我有一个名为“move”的动作(在delete,archive ...旁边),并根据给定的值(一个ID)将正确的ID传递给我的应用程序:

HTML(bootstrap):

if(workoutNameList.length<1){

    builder = new AlertDialog.Builder(Main2Activity.this);
    builder.setTitle("Workouts not created")
            .setMessage("Do you want to create a workout?")
            .setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    //Do nothing
                    dialog.dismiss();
                }
            })
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    Intent intent=new Intent(Main2Activity.this,NewWorkoutActivity.class);
                    startActivity(intent);
                }
            }).setCancelable(false);

    dialog = builder.create();
    dialog.show();

    }
    else {

        AlertDialog.Builder builder = new AlertDialog.Builder(Main2Activity.this);

        builder.setTitle("Select workout(s) to perform");
        builder.setMultiChoiceItems(workoutNameList, null, new DialogInterface.OnMultiChoiceClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {

            }
        });

        builder.setPositiveButton(R.string.Yes, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();

            }
        });

        builder.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();

            }
        });

        builder.setCancelable(false);

        AlertDialog dialog = builder.create();
        dialog.show();

    }
}

views.py:

<button class="SelectionAction" type="submit" name="move" value="id1">Move to id1</button>
<button class="SelectionAction" type="submit" name="move" value="id2">Move to id2</button>
<button class="SelectionAction" type="submit" name="move" value="id3">Move to id3</button>

我的问题:

我想在一个可折叠(下拉)按钮下面“堆叠”所有单独的移动按钮,就像这样。

下拉列表本身有效,但我无法将tag_selection_form = TagSelectionForm(request.POST or None) if tag_selection_form.is_valid(): if 'move' in request.POST: new_tag_id = request.POST['move'] new_tag_list = Tag.objects.get(user = request.user, id = new_tag_id) for item in tag_selection_form.cleaned_data['my_object']: item.tag_list.remove(tag_list) item.tag_list.add(new_tag_list) if 'delete' in request.POST: ... if 'archive' in request.POST: ... ... 添加到type="submit",并将<li><a>something</a></li>置于<button></button>内部,这会使css感到不安。

<li></li>

这件事的最佳前进方向是什么?

1 个答案:

答案 0 :(得分:0)

我最终在特定情况下改变了我自己的按钮css,以便它匹配我的下拉字段的布局

.btn-dropdown {
  text-align: left;
  padding-left: 20px;
  padding-right: 20px;
  width: 160px;
  background-color: rgba(0,0,0,0);
  border-color: rgba(0,0,0,0);
}
.btn-dropdown:hover {
  background-color: #f5f5f5;
}