Skip to main content

Customizing an Announcement List with jQuery

  • Chapter
  • First Online:
Creating Business Applications with Office 365
  • 1340 Accesses

Abstract

In this example, leadership wanted to have information about network alerts on our main SharePoint home page. At the Air Force Academy, we have two different networks (educational and military). Each alert would be characterized by order of importance as Outage, HAZCON, or Informational. My design was to have an Announcements list with unique permissions so that only the group that was allowed to add alerts could edit it. Everyone would have read access. I would customize the display using jQuery so that outages would be more prominent.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    This is important. In my first release of this functionality, I had locked the list down so much that only myself and my initial testers could read the list. When my squadron director looked at it, he got an error message. I first thought there was a problem with the JavaScript but I eventually realized it was a permissions problem.

  2. 2.

    Using [Today] in SharePoint filters is a powerful feature that I use often.

  3. 3.

    Notice how the use of contains allows us to pick up items where the Affected Network is EDU as well as the ones where it is both EDU and MIL.

  4. 4.

    This is rare good news when using jQuery with SharePoint. As you may notice in other examples, we typically have to use classes and loop through them because the generated HTML does not often have ids. We are not totally out of the woods since it is possible for both lists to have empty elements, which then results in one row having a different id. But testing revealed that the id always started with empty-WPQ. Listing 7 shows actual jQuery logic.

  5. 5.

    As we have seen earlier, the shorthand for this is the $(function () {} syntax.

  6. 6.

    The . means class.

  7. 7.

    We use the pipes to avoid the possibility that other text on the page might match our code. 1. Outage is possible on the rest of the page. |||1. Outage||| is not very likely to occur in other text.

  8. 8.

    Notice how we use the substring function to get rid of the numbers at the front. So className will be a value like AlertOutage.

  9. 9.

    The ∗ means contains in jQuery.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Jeffrey M. Rhodes

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Rhodes, J.M. (2019). Customizing an Announcement List with jQuery. In: Creating Business Applications with Office 365. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5331-1_5

Download citation

Publish with us

Policies and ethics