Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, you can't serialize a <code>table</code> object:</p> <p>HTML:</p> <pre><code>​&lt;table id="myTable"&gt; &lt;tr&gt; &lt;td&gt;&lt;input id='one' name='one' value='blah' /&gt;&lt;/td&gt; &lt;td&gt;&lt;input id='two' name='two' value='moreblah' /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ </code></pre> <p>JavaScript:</p> <pre><code>var serialized = ​$("#myTable").serialize(); debugger;​​​​​ </code></pre> <p>When the code pauses in the debugger, you can see that <code>serialized</code> is <code>""</code>, the empty string. MVC won't know how to model bind this to your IEnumerable, so it is null.</p> <p>On the other hand, if you do this:</p> <pre><code>var serialized = ​$("#one, #two").serialize(); debugger;​​​​​ </code></pre> <p>Then <code>serialized</code> will be equal to <code>"one=blah&amp;two=moreblah"</code>.</p> <p>Second, if you're actually binding to a <code>form</code> then all input elements inside the table will be correctly serialized. <strong>However</strong>, the names of your input elements are extremely important since you are trying to model-bind to an <code>IEnumerable&lt;CafePlaced&gt;</code>. Read this article by Phil Haack on model binding to a list: <a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow">http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx</a></p> <p>If you don't do it correctly, then MVC won't know how to model bind and your parameter will come through as null.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload