在Jquery ajax中使用动态ID验证html textarea ...
<div class="form-group">
<textarea type="text" data-contentId="<%= data.ContentId_PK %>" autofocus="autofocus" name="comment" class="form-control" id="txtComment<%= data.ContentId_PK %>" placeholder="Write a comment..." style="width:95%" maxlength="500"></textarea>
<i type="button" class="fa fa-location-arrow comment-submit" onclick="CommentSave('<%= data.ContentId_PK %>')" id="btnSave" value="POST">@*<input class="btn btn-success for" type="button" onclick="return CommentSave(this);" id="btnSave" value="POST" />*@</i>
<input type="hidden" class="hdncontent" value="<%= data.ContentId_PK %>" />
</div>
<script src="~/plugins/bower_components/twitterautosuggest/js/bootstrap-suggest.js"></script>
<script>
var data1 = [];
var peopId;
var StringArray = [];
$('#txtComment').suggest("@@", {
data: function (request, response) {
debugger;
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: rootDir + "Admin/People/GetSaleCommentPerson",
datatype: "json",
data: "{'FullName':'" + request + "'}",
success: function (data) {
data1 = response(data);
}
})
},
map: function (data) {
if (data.PeopId_PK != undefined) {
peopId += data.PeopId_PK + ',';
}
return {
//$('#hdnPeopleId').val() = + data.PeopId_PK +
value: data.FullName,
id: data.PeopId_PK,
text: '<strong id=' + data.PeopId_PK + '>' + data.FullName + '</strong> <small id=' + data.PeopId_PK + '>' + data.FullName + '</small>'
}
},
onselect: function (e, item) {
var KeyValue = {};
KeyValue.id = $(item.$element[0]).find('strong').attr('id');
KeyValue.Value = item.value;
StringArray.push(KeyValue);
//$('#hdnPeopleId').val(StringText);
//console.log(StringText);
},
});