Also coupled the website with jQuery Form Plugin which works seamlessly with ASP.NET MVC. jQuery Form Plugin basically provides various options such as
beforeSubmit - to validate before submitting data
success - to refresh/update content after success form submition
All works great, now what I actually need is to change data before submit so I have made some changes to jQuery Form Plugin as follows :-
..... ..... // give pre-submit callback an opportunity to abort the submit if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { log('ajaxSubmit: submit aborted via beforeSubmit callback'); return this; } // give addDataBeforeSubmit an opportunity to add custom data to be send along with form submit if(options.addDataBeforeSubmit) { var moreData = options.addDataBeforeSubmit(); $.each( moreData, function( i, item ) { var bExists = false; $.each( a, function( j, aitem ) { if(aitem.name == item.key){ aitem.value = item.value; bExists = true; } }); if(!bExists) { a.push({ name: item.key, value: item.value }); } }); } // fire vetoable 'validate' event this.trigger('form-submit-validate', [a, this, options, veto]); if (veto.veto) { log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); return this; } ..... .....
So this should cope with changing/adding new values to data that is to be sent for controller action (post)
Man is still the most extraordinary computer of all.
~John F. Kennedy
Great Article
ReplyDeleteASP.NET MVC Training
Online MVC Training
Online MVC Training India
Dot Net Training in Chennai
.Net Online Training
.net training online
Dot Net Online Training