Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay a message, using waitForKeyElements, every time a class is added to element
    primarykey
    data
    text
    <p>I have been learning javascript, jQuery, and userscripts, as well as how to user firebug, the last 3 days in the attempt to display information about a selected customer on the website desk.com. So far, other than a lot of learning, I have little to show for. I simply can't get the message to update when a new tab is selected.</p> <p><a href="https://i.stack.imgur.com/vucnR.png" rel="nofollow noreferrer" title="Link to posted image."><img src="https://i.stack.imgur.com/vucnR.png" /></a></p> <p>The purple tab is the selected one. All I need to do is when a new tab is selected display a message. For testing lets just put this message in an javascript alert(). Here is the HTML for the entire top bar that contains the Customer 1 tab.</p> <pre><code>&lt;ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner all"&gt; &lt;li class="a-icons ui-state-default ui-corner-top"&gt; &lt;a id="tab-tickets-label" href="#tabs-tickets"&gt; &lt;img width="18" height="16" src="https://d3jyn100am7dxp.cloudfront.net/images/a-icon-agent-list.png?1352530323" alt=""&gt; &lt;/a&gt; &lt;/li&gt; &lt;li class="a-icons ui-state-default ui-corner-top"&gt; &lt;a id="tab-kb" href="#tabs-kb"&gt; &lt;span&gt; &lt;img width="16" height="17" src="https://d3jyn100am7dxp.cloudfront.net/images/a-icon-knowledge-base.png?1352530323" alt=""&gt; &lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;li class="a-icons a-last ui-state-default ui-corner-top"&gt; &lt;a id="tab-search" href="#tabs-search"&gt; &lt;span&gt; &lt;img width="18" height="17" src="https://d3jyn100am7dxp.cloudfront.net/images/a-icon-search.png?1352530323" alt=""&gt; &lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;li class="ui-state-default ui-corner-top"&gt; &lt;a id="tab_header_ticket_id_73354627" href="#tabs-tid_88be8cc0-116b-0130-bf8a-12313f070061"&gt; &lt;span id="tabs-tid_88be8cc0-116b-0130-bf8a-12313f070061-closer" class="tab_closer"&gt; &lt;/span&gt; &lt;span&gt; &lt;span id="tabs-tid_88be8cc0-116b-0130-bf8a-12313f070061-icon" class="top_tab_icon"&gt; &lt;img width="20" height="20" src="https://d3jyn100am7dxp.cloudfront.net/images/interactions/20/a-phone.png?1352530323" alt=""&gt; &lt;/span&gt; &lt;span id="tabs-tid_88be8cc0-116b-0130-bf8a-12313f070061-customer-name" class="top_tab_customer_name"&gt;Customer 2&lt;/span&gt; &lt;/span&gt; &lt;span id="tabs-tid_88be8cc0-116b-0130-bf8a-12313f070061-service-level-bar" class="tab_service_level_indicator"&gt; &lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"&gt; &lt;a id="tab_header_ticket_id_73382205" href="#tabs-tid_88cd2df0-116b-0130-1271-12313f06c46f"&gt; &lt;span id="tabs-tid_88cd2df0-116b-0130-1271-12313f06c46f-closer" class="tab_closer"&gt;&lt;/span&gt; &lt;span&gt; &lt;span id="tabs-tid_88cd2df0-116b-0130-1271-12313f06c46f-icon" class="top_tab_icon"&gt; &lt;img width="20" height="20" src="https://d3jyn100am7dxp.cloudfront.net/images/interactions/20/a-email.png?1352530323" alt=""&gt; &lt;/span&gt; &lt;span id="tabs-tid_88cd2df0-116b-0130-1271-12313f06c46f-customer-name" class="top_tab_customer_name"&gt;Customer 1&lt;/span&gt; &lt;/span&gt; &lt;span id="tabs-tid_88cd2df0-116b-0130-1271-12313f06c46f-service-level-bar" class="tab_service_level_indicator"&gt; &lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>In the above code the element with the class 'ui-tabs-selected' is a <code>&lt;li&gt;</code>. This class is added to the newly selected tab every time a new tab is selected. I need my script to display a message, say "a new customer is selected", every time the class 'ui-tabs-selected' is added to a new element.</p> <p>Here is the scriptAttemp.user.js that I have tried most recently. </p> <pre><code>// ==UserScript== // @name deskNotifications2 // @namespace http://www.dutgriff.com/userscripts // @description Notifications for desk.com // @include https://nvows.desk.com/agent* // @version 1.0 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @grant GM_addStyle // ==/UserScript== waitForKeyElements ( ".ui-tabs-selected", addAlert ); function addAlert (jNode) { alert('The user was selected.'); } </code></pre> <p><br> <strong>The above script works great at first.</strong> It will display the message when the page loads. It will display the message again if I select a new tab. Then when I select a new tab again it does nothing. </p> <p>I need it to display the message every time a new tab is selected, or every time the '.ui-tabs-selected' is moved to a new location. This class can move to a new location by clicking other things on the page, not just by clicking on a different tab. </p> <p>For instance when there are no customer-tab selected I can click a button to view a new customer. This will open a new tab and place the '.ui-tabs-selected' on this new tab. All advice/links to info pages/constructive criticism is greatly appreciated. Sorry I am so new to all of this. </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