Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter DOM elements via JavaScript
    primarykey
    data
    text
    <p>I have elements that get created like this:</p> <pre><code>function appendCalendarEventToList(className, event) { var eventObject = { title: event.title, id: event.id, type: event.type, color: event.color, description: event.description, canReoccur: event.canReoccur, reoccurVal: event.reoccurVal, estHours: event.estHours, project: event.project }; var div = document.createElement("div"); div.className = 'external-event'; div.style.background = event.color; div.innerHTML = event.title; // store the Event Object in the DOM element so we can get to it later $(div).data('eventObject', eventObject); $(div).draggable({ helper: function () { $copy = $(this).clone(); $copy.data('eventObject', eventObject); $copy.css({ "list-style": "none", "width": $(this).outerWidth() }); return $copy; }, appendTo: 'body', zIndex: 999, revert: true, // will cause the event to go back to its revertDuration: 0 // original position after the drag }); $(className).append(div); $(div).qtip({ content: event.title, position: { target: 'mouse' }, // show: { event: 'click' }, hide: { event: 'mousedown mouseleave' }, style: { classes: 'custSideTip', width: 200, padding: 5, color: 'black', textAlign: 'left', border: { width: 1, radius: 3 } } }); return div; } </code></pre> <p>Every event has a project attribute as you see.</p> <p>However there are projects and tasks (and cases that can be ignored):</p> <pre><code>function refetchUnscheduled() { $.ajax({ type: "POST", url: "CalendarServices.aspx/GetUnscheduled", data: '', async:false, success: function (data) { var projects = '.project-container'; var tasks = '.task-container'; var cases = '.case-container'; $(projects).html(''); $(tasks).html(''); $(cases).html(''); var numProjects = 0; var numTasks = 0; var numCases = 0; $.each(data, function () { var className = ''; var url = ''; var typeName = ''; var crm = this.crm; switch(this.type) { case 'p': className = projects; url = 'ProjectViewFrame.aspx?id=' + this.id; typeName = 'Project'; numProjects++; break; case 't': className = tasks; url = 'TaskViewFrame.aspx?id=' + this.id; typeName = 'Task'; numTasks++; break; case 'c': className = cases; url = 'CaseViewFrame.aspx?id=' + this.id; typeName = 'Case'; numCases++; break; default: } var curDiv = appendCalendarEventToList(className, this); var curEvent = this; $(curDiv).bind('contextmenu', function (e) { $('#contextMenuContainer').html(''); var btn1 = createLink('Edit ' + typeName, 'context-elem-name'); $('#contextMenuContainer').append(btn1); $(btn1).on('click', function () { if (crm == '') showCalendarModal('Edit ' + typeName, url); else showCRM(crm); }) prepContextMenu(e); return false; }); }); changeUnscheduledHeaders(); } , error: function () { } }); } </code></pre> <p>Here is what I need that I am unsure how to do:</p> <p>I need an OR based filter: Given the following:</p> <pre><code>function filter(criteria,projects-div,tasks-div) { var words = criteria.split(' '); } </code></pre> <p>I need to first, hide all projects whos obj.data('eventObject').title contains one or more words.</p> <p>Then, once these are filtered: I need to first show all tasks whos project is visible,</p> <p>So: obj.data('eventObject').project is == to one of the visible project's project property.</p> <p>Then, I need to also show any tasks that have any of the words.</p> <p>All comparing must be case insensitive too.</p> <p>So say my criteria is 'hello world'</p> <pre><code>I show all projects with hello or world in the title. I show all tasks whos project attribute is visible after the first step I show all tasks whos title has hello or world </code></pre> <p>Thanks</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.
 

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