The edit disable function is malfunctioning

Currently, I am trying to disable the edit mode of the ion-searchbar.

This is what my code looks like -

<ion-searchbar  [disabled]="true"  style="padding: 0" class="add-place-item-divider" [(ngModel)]="mainTrail.source"></ion-searchbar>

However, the above code does not seem to be working correctly.

Answer №1

To implement the css style pointer-events: none;, I have made some adjustments to your code. Please use the updated version provided below:

<ion-searchbar  style="pointer-events: none;padding: 0" class="add-place-item-divider" [(ngModel)]="mainTrail.source"></ion-searchbar>

Answer №2

The Searchbar's disable attribute does not affect the inner input element. One potential solution could involve manipulating the DOM using ViewChild or ViewChildren...

Alternatively, Ganesh Pediredla's approach suggests implementing a method to enable/disable the component based on the pointer-events CSS property.

To achieve this, create a property that toggles a CSS class with the declaration pointer-events: none;

HTML

<ion-searchbar [ngClass]="{ 'no-pointer-events': disableSearchbar }" class="add-place-item-divider" [(ngModel)]="mainTrail.source"></ion-searchbar>

CSS

.no-pointer-events {
    pointer-events: none;
}

Component

public disableSearchbar: boolean = true;

toggleSearchbar(status: boolean): void {
    this.disableSearchbar = !this.disableSearchbar;
}

Check it out in action on stackblitz

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

Ways to retrieve a particular class attribute within a less mixin

Having trouble with the .aClass? .aClass { width: 20px; height: 20px; } Looking to dynamically calculate a width value in .anotherClass based on the width of .aClass. .anotherClass { width: .aClass.width } Unfortunately, the code snippet above is no ...

The form tag is failing to display the Name input field

Currently, I am facing an issue with the form tag rendering like this: <form method="post" action="AdminEditListTest.aspx" id="Form1" name="Form1"> This piece of code is considered as legacy and relies on document.Form1.XXX for DOM manipulation o ...

The Ionic AngularJS http service is failing to update the controller

I'm struggling to understand why my controller is receiving an empty array after calling the service, which triggers an http call. Here's how I have set up my app: Here is my app.js file: //App.js .state('myApp.sermonlists', { u ...

What could be causing the issue with Vite build and npm serve not functioning together?

After shifting from CRA to VITE, I am encountering a problem with serving my app. I successfully build my app using vite build. and can serve it using Vite serve without any issues. However, I want to use npm's serve command. Whenever I run vite bui ...

Looping through firebase keys with ngFor in Ionic2

In order to work with my firebase database structure, I am fetching data using the code snippet below: this.selectOptions = af.database.list('/select-options'); My objective is to create an ionic2 (angular2) form that includes two select inputs ...

"Facing a dilemma with Javascript's Facebox getElementById function - not fetching any

Utilizing facebox, I am initiating a small modal dialog with a form and attempting to retrieve the value from a text field on that form using javascript. Below is the HTML code: <div id="dialog-form95" style="display:none"> <div class="block"> ...

Using Ionic with Ubuntu to easily connect to MySQL and PHPMyAdmin

element, My current project involves creating a mobile app using Ionic on Ubuntu. I have successfully installed and configured phpmyadmin, which is now operational at http://localhost/phpmyadmin. Can someone guide me on how to configure Ionic to connect ...

Passing parameters to $http.get in Angular can be achieved by including them

I am attempting to send a params object to the $http.get() method. My params are structured as follows: var params = { one: value, two: value } I am trying to pass them into my function like this: $http.get('/someUrl', params) .success(fun ...

Maximizing the width of an absolute div element inside a container

Looking at this demo, you'll notice that the header remains fixed. However, my issue lies in getting the absolute <div> inside the <th> to occupy 100% of the width of the <th> When I set width: 100% for the <div>, it expands t ...

transforming a div container into an inline element using CSS

Hey there! I'm facing an issue with CSS where I am trying to change a div tag into inline. <div id="menu1"> <ul> <a href="#"> <li> one</li> </a> <a href="#"> <li> two</li> </a> <a h ...

What steps are involved in setting up personalized validation with react hook form?

Struggling to create a customized validation based on the existing validation code. Despite referencing this resource and attempting to implement the "Custom validation rules," I haven't been able to reproduce it successfully. The function isBefore s ...

Displaying content using Jquery's slideDown feature, overlapping existing content

I am working on displaying one piece of content over another using Jquery slidedown as an overlay. Despite adding z-index properties, I am struggling to make it work. My goal is to have the div with class "selection_nip" appear as an overlay on top of ano ...

Effortless script to make a URL request and display the response status | using JavaScript with jQuery

Is there a way to use JavaScript or jQuery to request a URL or website address and display the response code? For example: request www.google.com if (response_code = 200) { print "website alive" } else if (response_code = 204) { print "not found"; } ...

Methods for applying multiple styles within a div using the Document Object Model

Is there a way to add multiple style attributes using DOM `setAttribute` in JavaScript? I've tried doing it but it doesn't seem to work. Can someone provide guidance on how to achieve this? var modify = document.getElementById('options&apo ...

Including a property within a nested for-loop results in identical values being assigned to every parent for-loop

I am working with an array that contains data about playing cards (cardInfo). Below is a snippet of the array in the code. Since there can be duplicates of each card, I aim to utilize this data to generate a deck by storing its information in a new array ( ...

What is the process for creating a server-side API call?

I've designed a front-end application that uses an API to retrieve data. The problem I'm facing is that in order to access the API, I need to use an API Key. If I include the API key in the client-side code, it will be visible to users. How can I ...

Incorporating a new div element into a CSS layout with multiple

Could this be done? Imagine I have 15 divs, with 3 in each of the 5 columns of a multiple column CSS layout. I also have responsive code that adjusts the number of columns based on screen size. So, is there a way to insert a div between the 12th and 13th ...

Chrome preventing PDFs from being viewed on web pages by redirecting to a new tab with Top-Frame Navigations

Due to recent updates in Chrome version >=60, the ability to view PDF files through top-frame navigation options such as <A HREF=”data:…”> window.open(“data:…”) window.location = “data:…” has been blocked by Google. Discussion ...

Validation in Laravel appears to be ineffective when managing schedules

I have a table that contains schedules for each subject. I want to ensure that every schedule is unique and not duplicated. The table includes columns for room, teacher, time, day, and checker who verifies the schedule. It's essential that there are n ...

Encountering an issue while trying to create a user in Firebase

I am currently following a tutorial on Vue.js from Savvy Apps, which utilizes Firebase with Firestore. As the tutorial mentions that Firestore is still in Beta, I anticipate potential changes - and it seems like that might be happening in this case. While ...