Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Remember that because those are partial views does not mean that they do not belong the current DOM.</p> <p>Which means that if i have this js</p> <pre><code>function ClickEventListener(partialView) { alert(partialView.innerHTML); } </code></pre> <p>And i have this:</p> <pre><code> &lt;div id="view_1" onclick="ClickEventListener(this)"&gt; &lt;!--Your content--&gt; &lt;/div&gt; &lt;div id="view_2" onclick="ClickEventListener(this)"&gt; &lt;!--Your content--&gt; &lt;/div&gt; &lt;div id="view_3" onclick="ClickEventListener(this)"&gt; &lt;!--Your content--&gt; &lt;/div&gt; </code></pre> <p>Will work correctly. With that in mind you can comunicate the partial view with each other, edit its content(assigning id or class, that depends on how you want it) and you can have just one ajax to request de server for response and edit the desire partial view.</p> <p>Here example:</p> <p>Those are the 3 parital views that are already displayed</p> <pre><code> &lt;div id="view_1" onclick="ClickEventListener(this)"&gt; &lt;!--Your content--&gt; &lt;/div&gt; &lt;div id="view_2" onclick="ClickEventListener(this)"&gt; &lt;!--Your content--&gt; &lt;/div&gt; &lt;div id="view_3" onclick="ClickEventListener(this)"&gt; &lt;!--Your content--&gt; &lt;/div&gt; &lt;script&gt; function ClickEventListener(partialView) { var id; // base on which partial was click, send request the server a background color for example $.get('localhost/ChangeBGColor',{id: $(partialView).prop('id')},function(response){ $(response.partialTarget).css({background:response.color}); }) } } &lt;script&gt; </code></pre> <p>Server:</p> <pre><code>public JsonResult ChangeBGColor(int id){ object response; switch(id) { case 1: response = new { partialTarget= 'view_2',color = 'blue'}; break; case 2: response = new { partialTarget= 'view_3',color = 'black'}; break; case 3: response = new { partialTarget= 'view_1',color = 'green'}; break; } return Json(response,JsonRequestBehavior.AllowGet); } </code></pre> <p>If you need to refrest its content, you can do it as well.</p> <p><strong>An advice:</strong></p> <p>Partial view are quite tricky, if you have javascript code declared in one of them or all of them, does not matter if you remove the partial view. Variable, methods, object, etc, etc wil stay in memory, will not be remove it with it.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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