Having trouble with ion-item click not functioning in Ionic 3?

Working on my Ionic 3 project, I have encountered an issue with the ion-item click listener. The scenario is that I am adding text over a canvas and then attempting to change the style of the text (such as font-family, font-size, bold, and italic). The UI looks good, but unfortunately, my click listener on the ion-item is not functioning as expected. I am unsure of what mistake I may be making. Could someone please take a look?

1. HTML

<ion-row id="fontBar" *ngIf="isAddTextSelected">
    <ion-col col-4>
        <ion-item>
            <ion-label>Fonts</ion-label>
            <ion-select [(ngModel)]="selectedFont" (ionChange)="fontChange($event)">
                <ion-option *ngFor="let font of fonts" [value]="font.name" [ngStyle]="{'font-family': font.name}">{{font.name}}</ion-option>
            </ion-select>
          </ion-item>
    </ion-col>
  <ion-col col-4>
      <ion-item>
          <ion-label>Sizes</ion-label>
          <ion-select [(ngModel)]="selectedFontSize" (ionChange)="fontSizeChange($event)">
              <ion-option *ngFor="let fontSize of fontSizes" [value]="fontSize.size">{{fontSize.size}}</ion-option>
          </ion-select>
        </ion-item>
  </ion-col>
  <ion-col col-2>
      <ion-item tappable="true" (click)="selectBold()">
         <img src="assets/imgs/bold.png" />
      </ion-item>
  </ion-col>
  <ion-col col-2>
    <ion-item>
      <img src="assets/imgs/italic.png" (click)="selectItalic()"/>
    </ion-item>
  </ion-col>
  <!--<ion-col col-1>
      <ion-item>
        <img src="assets/imgs/underline.png"/>
      </ion-item>
    </ion-col>-->
</ion-row>

2. CSS

#fontBar {
        position: absolute;
        bottom: 7%;
        height: 50px;
        width: 100%;
    } 

3. Typescript file

selectBold(){
  debugger;
  if(this.selectedTxtIndex >= 0){
    if(this.textAreasList[this.selectedTxtIndex].bold==""){
      this.textAreasList[this.selectedTxtIndex].bold = "bold";
    }else{
      this.textAreasList[this.selectedTxtIndex].bold = "";
    }
  }
}

selectItalic(){
  if(this.selectedTxtIndex  >= 0){
    if(this.textAreasList[this.selectedTxtIndex].italic==""){
      this.textAreasList[this.selectedTxtIndex].italic = "italic";
    }else{
      this.textAreasList[this.selectedTxtIndex].italic = "";
    }
  }
}

fontSizeChange(selectedVal){
  if(this.selectedTxtIndex  >= 0){
      this.textAreasList[this.selectedTxtIndex].fontSize = selectedVal;
  }
}

fontChange(selectedVal){
  if(this.selectedTxtIndex  >= 0){
      this.textAreasList[this.selectedTxtIndex].fontFamily = selectedVal;
  }
}

Note- I added the debugger point, but click event not triggering. Even I search, according to that someone was saying change position absolute to relative. Even though it didn't worked.

Any assistance would be greatly appreciated.

Answer №1

Regrettably, I made an error by closing ion-content prematurely..

<ion-item> is designed to function within <ion-content> exclusively.

Once I properly closed <ion-content> after <ion-item>, everything started working smoothly..

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

Troubleshooting Problem: Difficulty accessing Controller in AngularJS Module

I am facing difficulties with communication between my application and a module that I have developed. Below is the AngularJS module that I created. (function (document, window) { 'use strict'; var piCart = angular.module('piCart& ...

Manipulate the timing of css animations using javascript

I am currently working with a progress bar that I need to manipulate using JavaScript. The demo of the progress bar has a smooth animation, but when I try to adjust its width using jQuery $($0).css({'width': '80%'}), the animation disap ...

What is the best way to retrieve a default property from a JavaScript literal object?

In the following example, a JS object is created: var obj = { key1 : {on:'value1', off:'value2'}, key2 : {on:'value3', off:'value4'} } Is there a clever method to automatically retrieve the default valu ...

ReactJS and MaterialUI: Creating a Dynamic Triangle Button Slider

I am facing a challenge in creating a triangle-shaped button for a slider in Material UI and ReactJS, instead of the current pizza slice shape. Here is an example of the desired outcome: https://i.sstatic.net/pNn93.png Here is the current state of the sl ...

Trouble Arising in Showing the "X" Symbol upon Initial Click in Tic-Tac-Toe Match

Description: I'm currently developing a tic-tac-toe game, and I've run into an interesting issue. When I click on any box for the first time, the "X" symbol doesn't show up. However, it works fine after the initial click. Problem Details: ...

The issue of drop shadows causing links to not work properly in Internet Explorer

I am currently working on a website design that features a fixed menu positioned behind the body. When the menu icon is clicked, some jQuery code shifts the body to the left. To create the effect of the fixed menu being positioned underneath, I have added ...

Using ASP.NET to bind Page.Header.DataBind() can lead to conflicts with angular service method calls

I'm encountering a strange issue with my ASP.NET master page and code behind. Whenever Page.Header.DataBind() is called, all the public methods on my angular service are executed as well. Below is a snippet of my angular service: myModule.service("m ...

Navigating through the CSS menu located in the main directory

I am facing an issue with accessing my CSS menu in different directories. In my root directory, I have a CSS menu that I want to use in subdirectories as well. However, when I navigate to a subdirectory, I find it difficult to go back to the main directory ...

Is there a way to assess Python code within a document's context using JavaScript in JupyterLab?

When using Jupyter Notebooks, I can create a cell with the following JavaScript code: %%javascript IPython.notebook.kernel.execute('x = 42') After executing this code, in another cell containing Python code, the variable x will be bound to 42 a ...

Attempting to achieve the effect where the entire row of a table changes color when the mouse hovers

I'm attempting to create a gradient effect for an entire row in a table when the mouse hovers over any cell within that row. Despite using what I believe is the correct CSS code, nothing changes upon mouseover (even though the original gradient appear ...

Replacing a div with another div can be achieved in a single swap

My goal is to swap one div with another div upon clicking using the provided code. It functions properly for a single instance. However, the issue arises when the class appears multiple times, causing all instances to change due to sharing the same class n ...

Incorporating Javascript into a .Net MVC 3 Project

It seems like there should be a straightforward solution to my question, but I'm struggling with it. I have an animation.js file that includes dependency_1.js and dependency_2.js in an include folder. Within my animation.js file, I load these dependen ...

Can an action be activated when the mouse comes to a halt?

Currently, I am having trouble triggering an event when a user stops moving their mouse over a div element. The current event is set up to show and follow another element along with the mouse movement, but I want it to only display when the mouse stops mov ...

The direction to the Excel document for conversion into JSON

I have a project in progress where I'm currently working on converting an Excel sheet to JSON. Once the data is converted, it will be displayed using jQuery Datatables on the browser. My code is functioning as expected, but I am encountering an issue ...

Learn how to display a web page in a tab view similar to the toggle device toolbar option

Is it possible to simulate the toggle device toolbar of a web page using JavaScript? https://i.stack.imgur.com/M9oB0.png For example, can we set up a webpage to always display in tab or mobile view like on YouTube? ...

In HTML5, a full-width video exceeds the size of the screen

When I have a video set to full width in a header with the width at 100%, the issue arises with the height. The video is too large, causing the controls to be out of view unless I scroll. Is there a solution to remedy this problem? <video width="100%" ...

When you click, transfer a single item from one array to another and modify the text according to the items in the array

How can I dynamically update a shopping cart feature on my website when a user clicks on the "addtocart" button? I want to create functionality where clicking on the button adds the corresponding product to the cart array, and updates the cart amount displ ...

Removing a Div with Dynamic Parameters

I'm struggling to implement a feature in my form that allows the user to add multiple entries, but I'm having trouble with the removal aspect. Here is the JavaScript code: var i = 1; var divContent = document.getElementById ...

Position an element with absolute positioning to the right edge of a relative element

I have a situation where I need to align the end of a position absolute element with the end of a relative element, but the relative element's width is not fixed and may vary based on content. This scenario arises as I am creating a custom dropdown m ...

Ensuring that all of the content is adaptable across various devices, from smartphones to high-definition 1080p screens

I am currently working on making my entire content responsive. While I have successfully made the background responsive using different @media resolutions, I am facing an issue with the image in the foreground that is not scaling accordingly. I tried putti ...