我一整天都在搜索,试图找出为什么代码在我的模态中没有传递任何值。我的代码有什么问题?感谢
public class MyBearsMyCollectionAdapter extends ArrayAdapter<MyBear> {
private Context context;
public MyBearsMyCollectionAdapter(Context context, int resource, List<MyBear> objects) {
super(context, resource, objects);
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.one_my_Bear_in_my_collection_display, parent, false);
}
LinearLayout myBearsMyCollectionLinearLayout = (LinearLayout) convertView.findViewById(R.id.my_Bear_linear_layout);
ImageView myBearImage = (ImageView) convertView.findViewById(R.id.my_Bear_image);
final MyBear myBear = getItem(position);
boolean isPhoto = myBear.getBearImageUrl() != null;
if (isPhoto) {
Glide.with(myBearImage.getContext())
.load(myBear.getBearImageUrl())
.into(myBearImage);
}
myBearsMyCollectionLinearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
BearPopup BearPopup = BearPopup.newInstance(myBear);
FragmentManager manager = ((MainActivity) context).getSupportFragmentManager();
BearPopup.show(manager, "BearPopup");
}
});
return convertView;
}
}
以下是我的模式中的内容:
<a href="#UpdateCrop" data-toggle="modal" class="fetchCCropID" data-toggle="modal" data-id="<?php echo $my_crop->cc_id; ?>"><?php echo $my_crop->main_crop; ?> </a>
和我的javascript:
<input type="text" name="crop_cultivated_id" id="crop_cultivated_id" value="" />
});
我在这里错过了什么吗?是否有必要的js版本? 我跟着这个小提琴。它工作但不在我的代码中。 https://jsfiddle.net/Au9tc/605/答案 0 :(得分:0)
如果您收到带有“id”的警告
,请尝试此检查$(document).on("click", ".fetchCCropID", function () {
var myCCropId = $(this).attr('id'); // used attr prop to get the Id.
alert(myCCropId);
$(".modal-body #crop_cultivated_id").val( myCCropId );
$('#crop_cultivated_id').modal('show');
})
以及检查格式是否正确 - data-id =“cc_id;?&gt;”&gt; main_crop; ?&GT;