I have the below HTML and jquery snippet, the new rows are added correctly and the the rows are deleted when clicked on which is expected but for the .delete_row click it isn't calculated the row count correctly after a row is deleted.  So say I have added 3 custom rows, I click to delete one row, it will delete and a alert box will display, if I click to delete a second row the process will alert twice and when I click to delete the third row the alert will pop up 3 times.  A single alert should only ever display when one row is removed but it's like the delete a row is incrementing by one on each run, cant see why though!?    $("#add_row").on("click", function(e) {   e.preventDefault();    var row_num = $(this).data("id");   var row_limit = 50;   var code_snippet = '&lt;div class="row"&gt;&lt;dd&gt;' + row_num + '&lt;/dd&gt;&lt;dt&gt;&lt;span class="delete_row" title="Delete Custom Row"&gt;&lt;i class="fas fa-times"&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;/div&gt;';    if (row_num &lt;= row_limit) {     $("#count").val(row_num);      $(code_snippet).insertBefore("#base");      row_num += 1;      $(this).data("id", row_num);   }    if (row_num &gt;= row_limit) {     // Disable button once limit reached     $(this).attr("disabled", true).addClass("disabled");   }    $(".delete_row").on("click", function(e) {     $(this).parent().parent(".row").remove();      alert("Deleted Row");      $("#add__row").data("id", ($("#add__row").data("id") - 1));   }); }); &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;fieldset&gt;   &lt;dl&gt;     &lt;div class="row row_header"&gt;Header Title&lt;/div&gt;      &lt;div class="row align_right" id="base"&gt;       &lt;input type="hidden" name="count" id="count" value="0" /&gt;       &lt;button id="add_row" data-id="1"&gt;Add New Row&lt;/button&gt;     &lt;/div&gt;   &lt;/dl&gt; &lt;/fieldset&gt;
112
I have a bit of code where I am looping through all the select boxes on a page and binding a .hover event to them to do a bit of twiddling with their width on mouse on/off.  This happens on page ready and works just fine.  The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won't have the event bound.  I have found this plugin (), but before I add another 5k to my pages with a plugin, I want to see if anyone knows a way to do this, either with jQuery directly or by another option.
61666
In reading I am not sure if the issue below could have something to do with needing a custom wordpress ajax handler? All of these functions are inside my functions.php file. I have a couple of PHP functions that are supposed to pass information from one to another. The an AJAX call to the final function should produce the final result through that call. Its not happening. My count results in 0 and I am not understanding why. If I replace my query with a static array like [44,55,99,33] then it will pass the values ok. Likewise if I keep the query and simply replace the $id in the query and make it a static id such as '20' then it works. I would think that the id was the issue then and it wasnt pulling properly but it seems to work ok just not pass? function idx(){     global $wpdb, $id;       $getId = $_SERVER['REQUEST_URI'];     $ecp = explode('/', $getId);     if($ecp[3] != ''){         $id = $ecp[3];     }         return $id; } add_action( 'after_setup_theme', 'idx' );  =============================================== function Total_Result(){     global $wpdb;     $id = idx();        /*$resultx = [44,88,59,52];*/ ;      $resultx = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT * FROM {$wpdb-&gt;prefix}custom_form_submission_conversation as cc LEFT JOIN {$wpdb-&gt;prefix}custom_form_submission as cs on cc.fsid ='$id' WHERE fsid='$id'&quot; ));          $resultxs = array($resultx);          $total_result =  count($resultxs[0]);     echo  $total_result; }  when I var_dump $resultx I get: array(3) { [0]=&gt; object(stdClass)#1256 (36) { [“cid”]=&gt; string(3) “167” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “yes” [“price_quote”]=&gt; string(4) “1140” [“posted_by”]=&gt; string(9) “dc_vendor” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “1” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” }   [1]=&gt; object(stdClass)#1257 (36) { [“cid”]=&gt; string(3) “186” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “Yes” [“price_quote”]=&gt; string(3) “602” [“posted_by”]=&gt; string(8) “customer” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “1” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” }   [2]=&gt; object(stdClass)#1258 (36) { [“cid”]=&gt; string(3) “188” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “yes” [“price_quote”]=&gt; string(4) “1017” [“posted_by”]=&gt; string(9) “dc_vendor” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “0” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” } }   so then I try and pass that data like so: function getvendorresponsestatus() {     global $wpdb; $id = idx();          $total_resultx = Total_Result($id);         die; }  Ive tried with and without the die();. The AJAX call is: setInterval(function(){     var ffiidd = jQuery('#ffiidd').val();     var ajaxurl = &quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;;          jQuery.post(ajaxurl, {         action: &quot;vendorAjaxprog&quot;,         ffiidd: ffiidd     }, function(data) {         console.log(data);         jQuery.post(ajaxurl, {             action: &quot;getvendorresponsestatus&quot;, //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; this is the action that calls the function             fsid : ffiidd         },         function(datas) {             console.log('+ datas);             jQuery('.cust_vendor_top').html(datas);         });         if(data == 0){}else{             jQuery('.ajaxreload').html(data);                                     }     });               }, 5000);/*==30 seconds==*/  So the question is why wont it pass along the query array information but it passes a basic array or it will pass if I change the id in the query to be static? I know the query is good because of when I var_dumped it, I have results before I get to the Total_Result() function.
105378
Use Case:  What i want is a list of records, and allow this user to choose 2 of those records, then click a button to go to a new VF page, if the user selects more than 2, i want him to get a notification of some kind saying you need to select 2 records, I do not want the page refeshed though.  Strategy:  I'm creating a wrapper class for the records like this:  and i have that part going by creating a custonm controller... I need the notification part working.   Problem:  I don't know how to call methods from the customController in javascript Also, i do not want to refresh the entire page. I just want them to go back to where they were. I was thinking a pop-up notification but I'm flexible..
32885
I have some html like this:  &lt;div id="1"&gt;     &lt;p&gt;         Volume = &lt;input type="text" /&gt;         &lt;button rel="3.93e-6" class="1" type="button"&gt;Check answer&lt;/button&gt;     &lt;/p&gt;     &lt;div&gt;&lt;/div&gt; &lt;/div&gt;   and some JS like this:  $("button").click(function () {     var buttonNo = $(this).attr('class');     var correct = Number($(this).attr('rel'));      validate (Number($("#"+buttonNo+" input").val()),correct);     $("#"+buttonNo+" div").html(feedback); });   What I'd really like is if I didn't have to have the class="1" on the button (I know numeric classes aren't valid, but this is a WIP!), so I could determine buttonNo based on the id of the parent div. In real life there are multiple sections looking like this.   How do I find the id of the div parenting the button. What would be a more semantic way to store the answer in the button code. I want to make this as foolproof as possible for a non programmer to copy and paste without breaking things!
77655
I'm looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like 'click' etc, but I'm building a tiny javascript library/plugin to handle some preview functionality.  I've got a script running to update some text in a dom element from a set of rules and data/user input I got, but now I need that same text shown in other elements that this script can't possibly know of. What I need is a good pattern to somehow observe this script producing the needed text.  So how do I do this? Did I overlook some builtin functionality in jquery to raise/handle user events or do I need some jquery plugin to do it? What do you think is the best way/plugin to handle this?
7050
When a post is deleted and the notification comes through, it scrolls over the inline flag bar:    The entire post also seems to capture clicks instead of letting them get to the flag bar. Looks like someone got a z-index wrong...
67596
So when you use the comment shortcut C, you get the comment box appearing. However, you will get a weird black box.  Here's a picture of before:           And afterwards:           And after reloading, it disappears! This seems weird.  And after looking at the HTML, this seems to be the problem:  &lt;div data-questionid="260187" id="question" class="question keyboard-selected"&gt;   After removing the class attribute, the box goes away.
110625
I hope this isn't a duplicate.  Similar questions that I found are over a year old.  I have seen cases where shortly after an upvote (perhaps on an old answer?), the summary in my user activity dropdown shows inconsistent counts:    Particularly, the Slid a div offscreen using jQuery answer shows +40, when it was only updated once yesterday.  Now, if this is a monthly total for this question, then it is correct, but when I refreshed later I got:    Now it shows +10, and other entries completely disappear.  So, what is this supposed to show me?  At the very least I am confused about what I am supposed to see here.  Here is another example:    This shows +20 for the same question as before, after I received a single upvote last night.  What gives?  You can see from my reputation that there was only a sinle upvote recently:
119097
I am seeing a weird indentation for questions loaded via AJAX (i.e., by clicking the n question(s) with new activity link). The following screenshot was taken before I clicked the link:  And this is after the new question was loaded:  A browser refresh resolves the problem (as can be expected). It was tested with Chrome 88 and Firefox 85 on  (Catalina).
119241
Hi I'm new to LWC and I have worked on the data table where it's iterated one so its shows like multiple tables in real-time now in each table the user will pick only one option from the selection so I have used max-row-selection =1 but here the problem is how to deselect the rows in Programmatically in LWC? &lt;template for:each={oppList} for:item=&quot;table&quot;&gt;       &lt;div class=&quot;slds-m-bottom_large&quot; key={table.category}&gt;         &lt;!-- &lt;div class=&quot;table-header&quot;&gt;           &lt;h2&gt;{table.category}&lt;/h2&gt;          &lt;/div&gt; --&gt;         &lt;lightning-card key={table.category} icon-name=&quot;custom:custom11&quot;&gt;             &lt;h1 slot=&quot;title&quot;&gt;{table.category}&lt;/h1&gt;             &lt;/lightning-card&gt;         &lt;lightning-datatable           data-id={table.category}           key-field=&quot;Id&quot;           selected-rows={preSelectedRows}           onsave={handleSave}           onrowselection={handleRowSelection}           suppress-bottom-bar=&quot;true&quot;           max-row-selection=&quot;1&quot;           draft-values={draftValues}           data={table.data}           columns={column}                    &gt;         &lt;/lightning-datatable&gt;       &lt;/div&gt;             &lt;/template&gt;  and my js  handleRowSelection = event =&gt; {         var selectedRows=event.detail.selectedRows;         if(selectedRows.length&gt;1)         {             var el = this.template.querySelector('lightning-datatable');             selectedRows=el.selectedRows=el.selectedRows.slice(1);             event.preventDefault();             return;         }          }  attached my sample screenshot. [![enter image description here][1]][1] Thanks in Advance.
51787
I want to be able to determine what group number is currently being processed to that I can treat the output of the first group differently than subsequent groups. Unlike rows, I do not see a way to find the current count of groups or loops through the view such that I could, for instance, do something like the following (i.e., classing group content by group iteration) - &lt;div class=&quot;item-list&quot;&gt;   &lt;h3 class=&quot;group-1&quot;&gt;{{ title }}&lt;/h3&gt;   &lt;ul class=&quot;group-1&quot;&gt;     {% for row in rows %}       &lt;li{{ row.attributes }}&gt;         {{- row.content -}}       &lt;/li&gt;     {% endfor %}   &lt;/ul&gt; &lt;/div&gt; &lt;div class=&quot;item-list&quot;&gt;   &lt;h3 class=&quot;group-2&quot;&gt;{{ title }}&lt;/h3&gt;   &lt;ul class=&quot;group-2&quot;&gt;     {% for row in rows %}       &lt;li{{ row.attributes }}&gt;         {{- row.content -}}       &lt;/li&gt;     {% endfor %}   &lt;/ul&gt; &lt;/div&gt; ... &lt;div class=&quot;item-list&quot;&gt;   &lt;h3 class=&quot;group-n&quot;&gt;{{ title }}&lt;/h3&gt;   &lt;ul class=&quot;group-n&quot;&gt;     {% for row in rows %}       &lt;li{{ row.attributes }}&gt;         {{- row.content -}}       &lt;/li&gt;     {% endfor %}   &lt;/ul&gt; &lt;/div&gt;
94566
I am having trouble with using a loop inside a tabular environment:  \newcounter{it} \setcounter{it}{0}  \begin{tabular}{ll}   \loop\ifnum\theit&lt;4     \addtocounter{it}{1}     Q &amp; A\\   \repeat \end{tabular}   I receive an error about argument of loop having an extra } and the compilation stops at &amp;. I don't get an error when it is a single column table, but even in that case the result is not as expected: I get a single execution of the loop in place of 4.  Can someone tell me what I am missing? Is there special considerations when using loops inside tabular?
48546
I've got some customer_comments split out into multiple rows due to database design, and for a report I need to combine the comments from each unique id into one row. I previously tried something working with this  trick but I can't recall it and must not have saved it. I can't seem to get it to work in this case either, only seems to work on a single row.  The data looks like this:  id  row_num  customer_code comments ----------------------------------- 1   1        Dilbert        Hard 1   2        Dilbert        Worker 2   1        Wally          Lazy   My results need to look like this:  id  customer_code comments ------------------------------ 1   Dilbert        Hard Worker 2   Wally          Lazy   So for each row_num there's really only one row of results; the comments should be combined in the order of row_num. The above linked SELECT trick works to get all the values for a specific query as one row, but I can't figure out how to make it work as part of a SELECT statement that spits all these rows out.   My query has to go through the whole table on its own and output these rows. I'm not combining them into multiple columns, one for each row, so PIVOT doesn't seem applicable.
68032
I have a table item having just one column name:-  name ----- toys shirt mobile Shirt speaker Toys ....  ....   I am trying to delete duplicate rows except one duplicated record with the help of below query  DELETE FROM ( SELECT `name`,`rownumber` FROM (SELECT GREATEST(0,@num := IF(`name` = @NAME,  @num + 1, 1),LEAST(1, LENGTH(@NAME := `name`))) AS rownumber,`name` FROM  item ORDER BY `name`) AS result1 ) AS result  WHERE rownumber &gt;1   The Inner query (Starts from SELECT name and ends with result1) returns individual auto incremented number for each repeating group but when i run entire query then it does not work.  I would like to know what changes i need to make in the inner query (contained in round braces) to delete duplicate rows.
24846
I am trying to work out how to get the value of table cell for each row using jQuery.  My table looks like this:  &lt;table id="mytable"&gt;   &lt;tr&gt;     &lt;th&gt;Customer Id&lt;/th&gt;     &lt;th&gt;Result&lt;/th&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;123&lt;/td&gt;     &lt;td&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;456&lt;/td&gt;     &lt;td&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;789&lt;/td&gt;     &lt;td&gt;&lt;/td&gt;   &lt;/tr&gt; &lt;/table&gt;   I basically want to loop through the table, and get the value of the Customer Id column for each row.  In the code below I have worked out that I need to do this to get it looping through each row, but I'm not sure how to get the value of the first cell in the row.  $('#mytable tr').each(function() {     var cutomerId =  }
20516
I've actually reached the bottom of Google trying to figure out how to add a css class to each row of a view.  The trick is that I need the class for each row to be dynamically determined based on some of the data from the node that the view pulls from.  The function that pulls this off neatly for the node is -   function pgc_preprocess(&amp;$variables) {   $node = $variables['node'];   if ($node-&gt;type == "event") {     $variables['event_class'] = '';     $num_trainers = $node-&gt;field_number_of_trainers[0]['value'];     $count = count($node-&gt;field_trainer);     if($count &lt; $num_trainers) {         $variables['event_class'] = 'red';     } else {         $variables['event_class'] = 'green';     }     return $variables;   } }   The point of this is to color code an event that hasn't had enough folks sign up.  There will be a list of events on the front page, and I need  them to be color coded also.  I really hope there some simple solution along the lines of -  function pgc_preprocess_views_view_unformatted(&amp;$variables) {   // Magic here, preferably having something to    // do with the function I already wrote. }   Just dropping &lt;?php print $event_class ?&gt; in the view .tpl doesn't do it.
86079
I recall there is a difference between some methods/properties called directly on the  class, and the identically named methods/properties on the  property. (Might have been the RowCount/Count property for which I read this.) The difference is one of them disregards , and the other respects/uses it.  In this particular case I'm wondering about the difference between  and . I can imagine one of them actually removes all rows, and the other one just marks them as deleted.  So my question is, is there a difference between the two Clear methods, and if so what is the difference?  (Oh, this is for .NET 1.1 btw, in case the semantics changed from one version to another.)