How to delete an item in an array inside of a modal and don't close the modal vue3? - vuejs3

I have a input file to select some files, as soon as I select them a preview modal is open containig the array, the user must delete one of the files if wanted but everytime I click do delete it, the modal just closes (the item is deleted btw).
Here's the template:
<div id="showFiles" class="modal fade" ref="modal" aria-labelledby="staticBackdropLabel">
<div class="modal-dialog modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header p-3 bg-soft-primary">
<h5 class="modal-title">Arquivos</h5>
</div>
<div class="modal-body">
<div v-for="file in files" :key="file.name" class="preview-card border rounded">
<div class="d-flex align-items-center p-2">
<b-img v-if="file.type != 'application/pdf'" class="img-thumbnail me-2" alt="200x200" width="200"
:src="generateURL(file)" data-holder-rendered="true" />
<iframe v-else class="img-thumbnail me-2" data-holder-rendered="true" frameBorder="0" scrolling="no" alt="200x200" width="200" :src="generateURL(file)" />
<div class="flex-grow-1">
<div class="pt-1">
<h5 class="fs-11 mb-1" data-dz-name="">
{{ file.name }}
</h5>
<p class="fs-9 text-muted mb-0" data-dz-size="">
<strong>{{ (file.size / 1024) / 1000 }}</strong> MB
</p>
<strong class="error text-danger" data-dz-errormessage="" />
</div>
</div>
<div class="flex-shrink-0 ms-3">
<b-button-group>
<b-button class="btn btn-sm btn-danger" #click="remove(files.indexOf(file))">
Excluir
</b-button>
</b-button-group>
</div>
</div>
</div>
</div>
<div class="modal-footer hstack gap-2 justify-content-end">
<button type="submit" class="btn btn-success btn-label chat-send waves-effect waves-light"
#click="formSubmit">
<i class="ri-send-plane-2-fill align-bottom label-icon" />Enviar
</button>
</div>
</div>
</div>
</div>
And here is the script of the delete option:
remove(i) {
this.files.splice(i, 1)
},
I've tried preventDefault(), #click.prevent and modal.show() right after the splice but none of it worked.

Related

How to use MDBootstrap Chat dynamically?

I am trying to user MdBootstrap 5's chat feature in my app.
This is what I have tried in the template but the thing is I need to refresh the page for it to work even though I am using SignalR in my backend.
<section style="background-color: #eee;">
<div class="container py-5">
<div class="row d-flex justify-content-center">
<div class="col-md-10 col-lg-8 col-xl-6">
<div class="card" id="chat2">
<div class="card-header d-flex justify-content-between align-items-center p-3">
<h5 class="mb-0">Chat</h5>
<button type="button" class="btn btn-primary btn-sm" data-mdb-ripple-color="dark">
Let's Chat
App
</button>
</div>
<div class="card-body" data-mdb-perfect-scrollbar="true" style="position: relative; height: 400px">
<div *ngFor="let message of (messageService.messageThread$ | async)">
<ng-container *ngIf="message.senderUsername !== currentUser!.userName">
<div class="d-flex flex-row justify-content-start">
<img src="https://mdbcdn.b-cdn.net/img/Photos/new-templates/bootstrap-chat/ava3-bg.webp"
alt="avatar 1" style="width: 45px; height: 100%;">
<div>
<p class="small p-2 ms-3 mb-1 rounded-3" style="background-color: #f5f6f7;">ouweee {{message.content}}</p>
<p class="small ms-3 mb-3 rounded-3 text-muted">{{message.messageSent | date:'medium'}}</p>
<span class="text-danger" *ngIf="!message.dateRead">(unread)</span>
<span class="text-success" *ngIf="message.dateRead">(read {{message.dateRead + 'Z' | timeago}})</span>
</div>
</div>
</ng-container>
<ng-container *ngIf="message.senderUsername === currentUser!.userName">
<div class="d-flex flex-row justify-content-end mb-4 pt-1">
<div>
<p class="small p-2 me-3 mb-1 text-white rounded-3 bg-primary"> Nouwweee {{message.content}}</p>
<p class="small me-3 mb-3 rounded-3 text-muted d-flex justify-content-end">{{message.messageSent | date:'medium'}}</p>
<span class="text-danger" *ngIf="!message.dateRead">(unread)</span>
<span class="text-success" *ngIf="message.dateRead">(read {{message.dateRead + 'Z' | timeago}})</span>
</div>
<img src="https://mdbcdn.b-cdn.net/img/Photos/new-templates/bootstrap-chat/ava4-bg.webp"
alt="avatar 1" style="width: 45px; height: 100%;">
</div>
</ng-container>
</div>
<form [formGroup]="messageForm" enctype="multipart/form-data" (ngSubmit)="createNewMessage()">
<div class="card-footer text-muted d-flex justify-content-start align-items-center p-3">
<img src="https://mdbcdn.b-cdn.net/img/Photos/new-templates/bootstrap-chat/ava3-bg.webp"
alt="avatar 3" style="width: 40px; height: 100%;">
<input type="text" class="form-control form-control-lg" id="exampleFormControlInput1"
placeholder="Type message" formControlName="content" name="content">
<a class="ms-1 text-muted" href="#!"><i class="fas fa-paperclip"></i></a>
<a class="ms-3 text-muted" href="#!"><i class="fas fa-smile"></i></a>
<button class="btn btn-primary" type="submit">Send</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
This is the page from which I extracted the MDBootstrap template :
https://mdbootstrap.com/docs/standard/extended/chat
Thanks for your time

How to make a button consistent on all size of display?

Image attached is the button from display of two different sizes (24inch and 13inch), button on 24inch display appears normal whereas add to cart button on 13inch display is broken.13inch display button 24 inch display button
<div class="row my-5" id="3">
<span id="lblArtworkId" style="display: none;">3</span>
<div class="col-2">
<div class="d-flex justify-content-center">
<a href="./">
<img src="upload/artworks/Artwork3.jpg" alt="" class="card-img-top" style="max-height: 8rem;">
</a>
</div>
</div>
<div class="col-6">
<div class="h-100 d-flex flex-column justify-content-between">
<span>
<a href="./" class="text-decoration-none text-muted fs-4">
Construction in Red, Blue & Yellow Drawing
</a>
</span>
<hr>
<p class="m-0">Artist: Karin White</p>
</div>
</div>
<div class="col-2">
<div class="h-100 d-flex align-items-center justify-content-center">
<span class="fw-bold">$ 1120.00</span>
</div>
</div>
<div class="col-2">
<div class="h-100 d-flex align-items-center justify-content-between">
<button id="btnRemove" class="btn btn-outline-danger">Remove</button>
<button id="btnCart" class="btn btn-primary">Add to Cart</button>
</div>
</div>
</div>
Welcome to stackoverflow.
You can use cols with a breakpoint prefix to adjust the layout. (e.g. col-xxl-2 col-3). Read Bootstrap Breakpoints and Grid options for more information. Also, since Bootstrap is sensitive to pixels, it is much better to consider pixels instead of inches.
Example:
<div class="container">
<div class="row my-5" id="3">
<span id="lblArtworkId" style="display: none;">3</span>
<div class="col-xxl-2 col-3">
<div class="d-flex justify-content-center">
<a href="./">
<img src="upload/artworks/Artwork3.jpg" alt="" class="card-img-top" style="max-height: 8rem;">
</a>
</div>
</div>
<div class="col-xxl-6 col-9">
<div class="h-100 d-flex flex-column justify-content-between">
<span>
<a href="./" class="text-decoration-none text-muted fs-4">
Construction in Red, Blue & Yellow Drawing
</a>
</span>
<hr>
<p class="m-0">Artist: Karin White</p>
</div>
</div>
<div class="col-xxl-2 col-4">
<div class="h-100 d-flex align-items-center justify-content-center">
<span class="fw-bold">$ 1120.00</span>
</div>
</div>
<div class="col-xxl-2 col-8">
<div class="h-100 d-flex align-items-center justify-content-between">
<button id="btnRemove" class="btn btn-outline-danger w-50 mx-1">Remove</button>
<button id="btnCart" class="btn btn-primary w-50 mx-1">Add to Cart</button>
</div>
</div>
</div>
</div>
Edit
Don't forget to include the required meta tags:
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

Bootstrap Modals - Modal id's different yet only one appears correctly

I'm having trouble with these modals in bootstrap. I have set the id for both differently yet only the first one appears when the "more" button is pressed. The second button does not show the required modal.
<div id="tf-team" class="text-center">
<div class="overlay" id="team1">
<div class="container">
<div class="section-title center">
<h4>Something</h4>
<h2 class="white">The Team</h2>
<img src="img/daag.png" alt="">
</div>
</div>
<div id="team" class="owl-carousel owl-theme row">
<!-- Team One -->
<div class="item">
<div class="thumbnail">
<img src="img/team/01.jpg" alt="..." class="img-circle team-img">
<div class="caption">
<h3>CEO name</h3>
<p class="blue">CEO</p>
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal1">More</button>
</div>
</div>
</div>
<!-- Team Two -->
<div class="item">
<div class="thumbnail">
<img src="img/team/03.jpg" alt="..." class="img-circle team-img">
<div class="caption">
<h3>Marketing Executive name</h3>
<p class="blue">Marketing Executive</p>
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal2">More</button>
</div>
</div>
</div>
These are the modals that should be appearing. The first modal appears as normal but the second doesn't even though the ID's are different.
<!-- Modal One-->
<div id="myModal1" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">text</h4>
</div>
<div class="modal-body">
<p><strong>text</strong></p>
<p>text</p>
<p><strong>text</strong></p>
<p>text
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- Modal Two-->
<div id="myModal2" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Dana</h4>
</div>
<div class="modal-body">
<p><strong>text</strong></p>
<p>text
</p>
<p><strong>text Tick</strong></p>
<p>text
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Does anyone have any ideas as to why this is happening?
You are just missing two closing </div> tags on the first modal.
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<div id="tf-team" class="text-center">
<div class="overlay" id="team1">
<div class="container">
<div class="section-title center">
<h4>Something</h4>
<h2 class="white">The Team</h2>
<img src="img/daag.png" alt="">
</div>
</div>
<div id="team" class="owl-carousel owl-theme row">
<!-- Team One -->
<div class="item">
<div class="thumbnail">
<img src="img/team/01.jpg" alt="..." class="img-circle team-img">
<div class="caption">
<h3>Jim Rae</h3>
<p class="blue">CEO</p>
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal1">More</button>
</div>
</div>
</div>
<!-- Team Two -->
<div class="item">
<div class="thumbnail">
<img src="img/team/03.jpg" alt="..." class="img-circle team-img">
<div class="caption">
<h3>Dana Apatachioae</h3>
<p class="blue">Marketing Executive</p>
<button class="btn btn-primary" data-toggle="modal" data-target="#myModal2">More</button>
</div>
</div>
</div>
<!-- Modal One-->
<div id="myModal1" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">text</h4>
</div>
<div class="modal-body">
<p><strong>text</strong>
</p>
<p>text</p>
<p><strong>text</strong>
</p>
<p>text
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- You are missing these two ending </div> tags. -->
</div>
</div>
<!-- Modal Two-->
<div id="myModal2" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Dana</h4>
</div>
<div class="modal-body">
<p><strong>text</strong>
</p>
<p>text
</p>
<p><strong>text Tick</strong>
</p>
<p>text
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

Ionic Slide Tabs Header Spacing is Off

The spacing between the headers on my tabs when using ionic-slide-box-tabs .
It works fine in the browser, but the spacing is off on my android device.
The markup looks like the following
<ion-slide-box style="position:absolute; bottom: 0;left: 0;right: 0; " slide-tabs-scrollable="true" on-slide-changed="slideHasChanged($index)" class="has-header" show-pager="false" ion-slide-tabs>
<ion-slide ion-slide-tab-label="{{category.name}}" ng-repeat="category in model.selectedMenu.categories" on-slide-changed="slideHasChanged($index)">
<ion-content style="margin-top:44px;margin-bottom:44px;" overflow-scroll="false" scroll="true">
<ion-item class="row col item-list" style="padding:0px;margin:0px;" ng-repeat="item in category.items | orderBy: 'name' track by item.id">
<img ng-src="{{item.imagePath}}" class="col" style="height:{{height}}px;padding:0px;"></img>
<div class="gradient-image" style="height:{{height/2 + height/6}}px;position:absolute;width:100%;bottom:0px;margin-bottom:45px;">
<div style="position:absolute;top:0px;width:100%;margin-top:{{height/8}}px">
<div>
<p class="item-title">{{item.name | uppercase}}</p><br>
</div>
<div class="item-text-wrap">
<p class="item-description">{{item.description}}</p><br>
</div>
</div>
</div>
<div class="row item action-panel padding" style="margin:0px;">
<div class="col action">
<div class="info" style="text-align:center;font-size:20px;">{{::item.price | currency}}</div>
</div>
<div class="col action">
<button ng-click="count = removeItem(item)" class="col button icon action" ng-class="{ 'minus-button': item.quantity > 0}" ng-disabled="item.quantity == 0">
<i class="icon ion-minus action action-icon" ng-if="item.quantity > 0"></i>
<i class="icon ion-minus action action-icon" style="color:#fff;" ng-if="item.quantity == 0"></i>
</button>
</div>
<div class="col action">
<div class="info" ng-class="{'light':item.quantity == 0}" style="text-align:center;font-size:24px;" ng-model="item.quantity"><b>{{item.quantity}}</b></div>
</div>
<div class="col col-30">
<button ng-click="count = addItem(item)" class="col button icon primary-action">
<i class="icon ion-plus primary-action-icon"></i>
</button>
</div>
</div>
</ion-item>
</ion-content>
</ion-slide>
</ion-slide-box>

Html Agilitypack Getting Outer Items

i need to get <div class="month">May 2015</div> and <div class="author">Alex Xander</div> by id="duyuru3483". How can i reach upper divs (XPATH code):
<div class="item">
<div class="dateBox">
<div class="month">May 2015</div>
<div class="day">07</div>
</div>
<div class="mainInfo">
<div class="title">
<a href="#" class="text-justify" data-toggle="modal" data-target="#duyuru3483">
2014-2015 Yılı Mezuniyet Töreni Hk.
</a>
<div class="modal fade" id="duyuru3483" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="background-color: #009E49;">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">
<div class="duyuruBaslik">2014-2015 Yılı Mezuniyet Töreni Hk.</div>
</h4>
</div>
<div class="modal-body">
<div class="duyuruMetni"> Mezuniyet törenine katılmak için yapılmasıgereken işlemler ve doldurulması gereken form ektedir. </div>
<hr>
<div class="author" > Ek : <a style="color:##428bca" href="../files/19_mezuniyet.rar">indir</a> </div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Kapat</button>
</div>
</div>
</div>
</div>
</div>
<div class="author">Alex Xander</div>
One option is to use Ancestors:
var modal = doc.GetElementbyId("duyuru3483");
var parent = modal.Ancestors()
.Single(e => e.Attributes["class"] !=null &&
e.Attributes["class"].Value == "item");
Another option is to use XPath:
var parent = doc.DocumentNode
.SelectSingleNode("div[#class='item'][//div[#id='duyuru3483']]");
(you can algo get directly to .dateBox using:
div[#class='item'][//div[#id='duyuru3483']]/div[#class='dateBox']
And, of course, you can just use ParentNode, but that is less robust:
var parent = modal.ParentNode.ParentNode.ParentNode;
All of these get you to .item - it should be easy getting the data from there.

Resources