jquery - Change FORM element to something else or delete it while keeping all child elements -


i've integrated asp.net mvc sharepoint site. works great. i'm using default sharepoint master page (~masterurl/default.master namely). problem particular master page has whole page wrapped in form element while sharepoint pages normal asp.net webform pages.

my mvc content should have it's own form , input elements i'd submit server. ajax calls not problematic. i'm not able use $("form").serializearray() if keep original form element. nonetheless normal postbacks problematic, since there's webform functionality on submit events , send way data server.

i using normal postbacks ajax postbacks. main problem being normal postbacks.

so have 2 possibilities both should run on $(document).ready():

  1. delete form element , keep other content is. in jquery mean prepend form element div, move content div , delete form.
  2. directly change form element div. faster in terms of browser processing, don't know how it.

so if can elaborate solution 2. , provide input on these 2 possible solutions: 1 should done , why.

edit

there's third possibility well. create input elements neede containe them inside div element. when user want submit form (div not form anyway) could:

  1. dynamically call $("div.form").serializearray()
  2. create form element
  3. populate serialized values
  4. append form body
  5. submit it.

seems tedious work. still first 2 solutions seem simpler.

if you're submitting via $.ajax() i'd go .serialize() of elements directly, this:

$.ajax({   url: "path/action",   type: "post",   data: $("#somecontainer :input").serialize(),   success: function(data) {     //do   } }); 

or shorter $.post() version:

$.post("path/action", $("#somecontainer :input").serialize(), function(data) {   //do }); 

this doesn't require <form> generation or other trickery, normal jquery ajax post (or get, whatever's needed).


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -