asp.net mvc - Adding New Items With jQuery And No Ajax -


i wanting enable user add items view model jquery , no ajax.

the reason not want use ajax because without ajax user must click save, , creates less chance of them accidentally changing something.

i have working, seems bit of hack.

'<tr>'+ '<td class="detail-priority">' + '<input id="complianceseveritylevel_4__complianceseveritylevelid" type="hidden" value="-1" name="complianceseveritylevel[4].complianceseveritylevelid" data-val-required="the complianceseveritylevelid field required." data-val-number="the field complianceseveritylevelid must number." data-val="true">' + '<input id="complianceseveritylevel_4__priority" class="valid" type="text" value="0" name="complianceseveritylevel[4].priority" data-val-required="the priority field required." data-val-number="the field priority must number." data-val="true">' + '</td>' + '</tr>' 

i copy html asp.net mvc generates, set id value -1 knows create new entry.

i have generate array index. doesn't seem optimal way go this. there few articles on subject involve ajax.

is there anyway can more efficently?

what can add "new" item model in controller (or in view if prefer that). way have @ least 1 item in collection.

now, instead of adding hardcoded html (which have update whenever change view), can .clone() last item on page , update necessary ids.

when submitting, can either disable input fields of last item in html empty item isn't included, or can check server-side exclude last item.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -