Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS + jQuery - Unable to perform .toggle() and repeated jQueryTemplate Item [I must warn you this is a bit overwhelming]
    primarykey
    data
    text
    <p>Okay here we go:</p> <h1>Stream.html (Template file)</h1> <pre><code>&lt;div class="streamItem clearfix"&gt; &lt;input type="button" /&gt; &lt;div class="clientStrip"&gt; &lt;img src="" alt="${Sender}" /&gt; &lt;/div&gt; &lt;div class="clientView"&gt; &lt;a href="#" class="clientName"&gt;${Sender}&lt;/a&gt; &lt;p&gt;${Value}&lt;/p&gt; &lt;p&gt;${DateTime}&lt;/p&gt; &lt;div class="itemGadgets"&gt; &lt;ul&gt; &lt;li class="toggleInput"&gt;Value&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="inputContainer"&gt; &lt;input type="text" value="" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="spacer" /&gt; </code></pre> <h1>Default.aspx (jQuery)</h1> <pre><code>$('.toggleInput').live('click', function () { $(this).parent().parent() .find('.inputContainer').toggle(); $(this).parent().parent().find('.inputContainer') .find('input[type=text]').focus(); }); </code></pre> <h1>Update: The above has been changed to:</h1> <pre><code> $('.toggleInput').live('click', function () { $(this).closest(".clientView").find(".inputContainer").toggle() $(this).closest(".clientView").find(".inputContainer") .find('input[type=text]').focus(); }); </code></pre> <p><strong>Issues with jQuery:</strong></p> <ol> <li><p>I have comments that belong to each <code>.streamItem</code>. My previous solution was to use <code>ListView</code> control as follows:</p> <pre><code>&lt;ItemTemplate&gt; &lt;asp:Panel ID="StreamItem" CssClass="StreamItem" runat="server"&gt; ... &lt;!-- Insert another nested ListView control here to load the comments for the parent stream. --&gt; </code></pre> <p>So as you can see, this is not a solution since I started using jQuery Templates and I am fetching the data using the following jQuery <code>$.ajax</code> method:</p> <pre><code>$.ajax({ type: 'POST', url: 'Services.asmx/GetStream', data: "{}", contentType: 'application/json', success: function (Stream) { $.get('Templates/Stream.html', function (template) { $.tmpl(template, Stream.d).appendTo("#Stream"); }); } }); </code></pre> <p><strong>How can I resolve this without using the old <code>ListView</code> solution but by using jQuery Templates to load the comments whenever I am getting data for a specific stream?</strong> I am using a simple <code>WebMethod</code> to return my data as follows:</p> <pre><code>[WebMethod] public List&lt;Stream&gt; GetStream() { List&lt;Stream&gt; Streams = Stream.GetRange(X, X, HttpContext.Current.User.Identity.Name); return Streams; } </code></pre></li> <li><p>I am looking for a way to handle the <code>.toggleInput</code> click event. I need check if <code>.Comments</code> (a main container for the (to be comments container <code>&lt;div&gt;</code>)) has children (or more than one <code>.commentItem</code>). If so, then I need to show that <code>.inputContainer</code> and hide all the other <code>.inputContainer divs</code> with .Comments <code>size() == 0</code> if they're visible. </p></li> </ol> <p>Please see the image below:</p> <p><img src="https://i.stack.imgur.com/asHWr.png" alt="enter image description here"></p> <h1>Update: CSS Issue below is resolved. (I had a conflict)</h1> <pre><code>#globalContainer div { float : right; position : relative; display : inline-block; /* &lt;-- Thank you Firebug. */ } </code></pre> <h1>Default.aspx (Partial CSS)</h1> <pre><code>div.streamItem div.clientView { float : left; width : 542px; } div.streamItem div.clientView p { margin : 5px 0 0 0; font-size : 10pt; } div.streamItem div.clientView div.inputContainer { display : none; /* Doesn't hide .inputContainer */ padding : 2px; background-color : #f1f1f1; } </code></pre> <p><strong>Issues with CSS:</strong></p> <p>On page load, <code>display: none;</code> has no effect.</p> <p>That's it! If you're reading this I'd like to thank you for your time and thoughts! :)</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.
 

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