Exploring the functionality of Semantics UI components without the need for writing any extra jQuery scripts

In my current project, I am utilizing Semantics UI. As an example, when using the dropdown component, I need to call a function in my script tag, like so:

<script type="text/javascript">
 $('.dropdown')
    .dropdown()
  ;
</script>

Do you happen to know of any alternative method that eliminates the need for additional scripting? Similar to how Bootstrap and other frameworks handle it?

Answer №1

Some of the modules in Semantic UI have alternative versions that do not rely on javascript, but they may have limited functionality or a basic design.

To find the equivalent for each module, you will need to refer to the documentation. For instance, Dropdown has both a version with and without javascript, known as the simple version.

$(function(){
  $('#firstDropdown').dropdown();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css" rel="stylesheet"/>

<div class="ui header">With Javascript</div>
<select id="firstDropdown">
  <option value="">Select ...</option>
  <option value="one">One</option>
  <option value="two">Two</option>
  <option value="three">Three</option>
</select>

<div class="ui header">Without Javascript</div>
<select id="secondDropdown" class="ui selection dropdown">
  <option value="">Select ...</option>
  <option value="one">One</option>
  <option value="two">Two</option>
  <option value="three">Three</option>
</select>

<div class="ui header">
  Simple Dropdown
  <div class="sub header">Does not require javascript to initialise, but will require it to handle selection &amp; behaviour</div>
</div>
<div class="ui compact menu">
  <div class="ui simple dropdown item">
    Dropdown
    <i class="dropdown icon"></i>
    <div class="menu">
      <div class="item">Choice 1</div>
      <div class="item">Choice 2</div>
      <div class="item">Choice 3</div>
    </div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Obtaining the identifier of dynamically inserted text components

One of the features on my ASP page allows users to load items into textboxes. Since the number of elements will vary and is not known at the outset, I utilize Javascript to generate new textboxes as needed. <script> var sessionId = 0; function cre ...

What are the steps to utilize WebRTC in transmitting a real-time webcam feed from the user interface to the server?

Currently, I am in the process of developing a simple Streamyard alternative that can capture live webcam streams from users' browsers and transmit them to the backend for further processing and conversion into the necessary format for streaming on pl ...

Identify the client's network disconnection using socket.io in NodeJs

Currently, I am in the process of developing an application using node.js and socket.io. One of the requirements for my app is to be able to detect when the client-side connection to the internet is lost and then trigger a manual or automatic disconnection ...

Configuring IP Whitelisting for Firebase Cloud Functions with MongoDB Cluster

What is the process for including my Firebase Cloud Functions in the IP whitelist of my MongoDB cluster? Error Message: ...

Utilizing variables upon the page being refreshed

Is there a way to retain certain data even when the page is refreshed? I have some values stored in an array and would like to keep them without losing them upon refreshing. ...

Attempting to eliminate redundant data retrieved from an XML file being presented on my webpage

I need help deleting duplicate artists that appear when retrieving information from an XML file using JQuery. How can I achieve this? Check out the JS file below: $(function(){ $(window).load(function(){ $.ajax({ url: 'http://imagination ...

What is the best way to adjust the size of this text using CSS?

I'm encountering an issue with font size in CSS. In the code below, you can see that I have a .post class containing < pre > tags nested inside it. Shouldn't the CSS styling for the pre tags work as intended? Despite setting the font size t ...

What is the best way to customize multiple checkboxes in React Native?

I need help with implementing checkboxes in my app using react-native-check-box. I have tried creating 4 checkboxes, but the text inside them is not aligning properly. The boxes are rendering one above the other instead of staying on the same line. I want ...

Concerns with combining key value pairs in Typescript Enums

Could you help me figure out how to properly implement an enum in my drop-down so that I can only display one value at a time? Currently, I am seeing both the key and the value in the list. This is my enum: export enum VMRole { "Kubemaster" = 0, "Kub ...

Unable to launch React Native project on emulator now

Something seems off with my App as it won't start up on my AS Emulator. Everything was running smoothly yesterday, but today it's not working - possibly due to me moving the npm and npm-cache folders, although they are configured correctly with n ...

Usage of Google Charts within an Ajax partial in Rails 3.1

My experience working with Google charts has been smooth so far, but I've hit a roadblock where I need to display a chart inside an Ajax-rendered partial. Nothing is showing up, and I suspect it's because the JavaScript trigger to build the char ...

What could be the reason that angularjs html template requests aren't appearing in the top websites when viewed in a

After referring to the link , I discovered a way to determine which programming tools different sites use for application development. However, when I debug HTTP requests using Firebug, I noticed that HTML requests are not explicitly shown in the log. Alt ...

The prompt "npm run build" command resulted in a 126 Vercel exit status

While attempting to upload my website with Webpack to Vercel from the repository, I encountered an error during the build process: Skipping build cache, deployment triggered without cache. Cloning completed: 2.089s Running "vercel build" Vercel CLI 31.2.3 ...

Checking if the Cursor is Currently Positioned on a Chart Element in Word Addin/OfficeJS

I am looking for a way to determine if the document cursor is currently positioned inside of a Chart element using the Microsoft Word API. My current application can successfully insert text, but when I attempt to insert text into the Chart title, it ends ...

What is the best way to iterate through a multi-dimensional array and only load a single section at a time? - Using JavaScript

I have a massive multidimensional JavaScript array object that stores coordinates of numerous earthquakes. Here is an example: var earthquakeArray = [ [ 0 : { "place": "home", "lat": "30", ...

Tips for optimizing the performance of nested for loops

I wrote a for loop that iterates over 2 enums, sending them both to the server, receiving a value in return, and then calculating another value using a nested for loop. I believe there is room for improvement in this code snippet: const paths = []; for awa ...

Incorporating a multimedia player onto a webpage with HTML

I'm trying to incorporate music files directly into a website, similar to having a small mp3 player on the page. I want visitors to have the ability to play, pause, and control the songs using custom-designed buttons. What is the best way to code the ...

Puppeteer's scrolling function struggles to retrieve fresh page data

An Issue with Retrieving HTML Source from Google Maps My current challenge involves retrieving the entire HTML source of a Google Maps page using puppeteer. The specific issue I am encountering relates to the load-on-scroll feature of the page. Despite th ...

Using AngularJS to execute jQuery code after the page has finished loading

I have a carousel of images on my website: Here is the code I am using: <div id="carousel"> <ul class="bjqs"> <li ng-repeat="image in dealer.images"><img src="{{image}}" alt="{{image}}" /></li> </ul& ...

Struggling with handling various active states in ReactJS?

Good day to all my fellow stackOverflowers! I'm looking for advice on how to maintain the independence of active states when clicked. I'm struggling to prevent them from affecting each other. Each button starts with an active status of false by d ...