jQuery UI Dialog not opened for second time - html

jQuery UI Dialog not opened for second time
I have series of data as below
html
<a href="javascript:void(0);" class="popup_1" pop_val="abc" >Dummy Text</a>
<a href="javascript:void(0);" class="popup_1" pop_val="vbg" >Dummy Text</a>
<a href="javascript:void(0);" class="popup_1" pop_val="aere" >Dummy Text</a>
<a href="javascript:void(0);" class="popup_1" pop_val="vbb" >Dummy Text</a>
<div id="dialog" title="TEST MODAL">
Loading...
</div> <!-- dialog -->
jQuery
Script One
This one runs perfect
<script>
$(".popup_1").bind('click', function (e) {
var pop_value = $(this).attr("pop_val");
console.log(pop_value);
$("#dialog").dialog({
autoOpen: false,
width: 700,
modal: true,
});
$("#dialog").dialog("open");
});
</script>
Script Two
This script, runs for the first time and second time its not working,
instead it gives an error
Uncaught TypeError: Object [object HTMLAnchorElement] has no method
'attr'
[ var pop_value = $(this).attr("pop_val"); ]
<script>
$(".popup_1").bind('click', function (e) {
var pop_value = $(this).attr("pop_val");
console.log(pop_value);
$("#dialog").dialog({
autoOpen: false,
width: 700,
modal: true,
});
$.post("ajx_page.cfm?PID="+pop_value, {}, function(return_data){
$("#dialog").html(return_data);
});
$("#dialog").dialog("open");
});
</script>
I have no clue, why it throws an error. I have gone throught other question on SO, but could not get perfect solution.

Related

I am getting more than one Confirmation Dialog boxes in primeng

I am trying to implement confirm dialog using primeng in my angular web application. When I click the button which is supposed to call the method, I get the dialog twice.
I put a console log to check if the method is getting called twice, Turns out, it is getting called once on click. Below is the code.
HTML :
<div class="card">
<p>{{eachsecret.title}}</p>
<p>{{eachsecret.date}}</p>
<div class="container">
<i class="pi pi-eye"></i>
<i class="pi pi-download" (click)="download(eachsecret.sid)"></i>
<i class="pi pi-pencil"></i>
<p-confirmDialog [style]="{width: '50vw'}" [baseZIndex]="10000" rejectButtonStyleClass="p-button-text"></p-confirmDialog>
<i class="pi pi-trash" (click)="delete(eachsecret.sid)"></i>
</div>
</div>
Delete method :
delete(sid) {
console.log("confirmation dialogue method called");
this.confirmationService.confirm({
message: 'Are you sure that you want to proceed?',
header: 'Confirmation',
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.httpClient.delete(environment.baseURL+'/secret/'+sid, { observe: 'response'}).subscribe(data => {});
this.messageService.add({severity:'info', summary:'Confirmed', detail:'You have accepted'});},
reject: () => {this.messageService.add({severity:'error', summary:'Rejected', detail:'You have rejected'});}
});
}
Assign a key to both confirm method call and html code.
HTML:
<p-confirmDialog [style]="{width: '50vw'}" [baseZIndex]="10000" rejectButtonStyleClass="p-button-text" key="myDialog"></p-confirmDialog>
TS:
this.confirmationService.confirm({
message: 'Are you sure that you want to proceed?',
header: 'Confirmation',
icon: 'pi pi-exclamation-triangle',
accept: () => {
this.httpClient.delete(environment.baseURL+'/secret/'+sid, { observe: 'response'}).subscribe(data => {});
this.messageService.add({severity:'info', summary:'Confirmed', detail:'You have accepted'});},
reject: () => {this.messageService.add({severity:'error', summary:'Rejected', detail:'You have rejected'});},
key: "myDialog"
});

Kendo UI grid accessibility for button e.g. Excel Export

How can I set the icon of the grid button to aria-hidden="true"?
$("#grid").kendoGrid({
toolbar: ["excel"],
excel: {
allPages: true
},
dataSource: {
transport: {
read: {
url: "https://demos.telerik.com/kendo-ui/service/products",
dataType: "jsonp"
}
},
pageSize: 10
},
pageable: true
});
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2020.1.219/styles/kendo.default-v2.min.css"/>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2020.1.219/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2020.1.219/js/kendo.all.min.js"></script>
<div id="grid"></div>
Current html:
<div class="k-header k-grid-toolbar"><a role="button" class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-file-excel"></span>Export to excel</a></div>
Desired result:
<div class="k-header k-grid-toolbar"><a role="button" class="k-button k-button-icontext k-grid-excel" href="#"><span aria-hidden="true" class="k-icon k-i-file-excel"></span>Export to excel</a></div>
The icon has class k-i-file-excel. Use that class to select the element and set the attribute:
$("#grid .k-i-file-excel").attr("aria-hidden","true");
You don't need to do anything.
Test your application with a keyboard and screen reader. Since you're not modifying tab indices, either the outer <a> tag will get the focus (and should be correctly announced as "Export to excel"), or nothing will. Your user will know what the button is for.

Cannot create a button in a draggable list

I have an ng-nestable div and inside that there is a simple button that has an ng-click event hooked up to it. When I click on that button it doesn't register the click but rather starts the drag and drop process.
Here is my HTML Code,
<div class="col-sm-1 text-right"><button ng-click="fnEditHomeSlider({{$item.SliderID}})" class="btn btn-blue btn-sm" nestable-button><i class="fa fa-edit"></i> Edit</button>
</div>
Note: Is your code something like, try it, Hope it could also matches your need or give us your code
1.) Create a custom directive
myApp.directive('nestableButton', function() {
return {
restrict: 'A',
link: function(scope, element) {
$(element).on("mousedown", function(e) {
e.preventDefault();
return false;
});
$(element).on("click", function(e) {
e.preventDefault();
window.location = $(this).attr("href"); //if you want your URL to update
return false;
});
}
};
});
2.) In HTML
</i>
</i>
Lokesh Kakran is right about this.
And here is live demo project about your solution.
demo : http://pathik.linedeer.com/ng-nestable/
code : https://github.com/pathikdevani/ng-nestable/blob/gh-pages/index.html

pop up and grid view on one button

I try to call gridview and pop up on one button click
pop up
<script type="text/javascript">
$(function () {
$("#divcontainer").dialog({
modal: true,
autoOpen: false,
title: "Chart",
width: 600,
height: 450
});
$("#search_data").click(function () {
$("#divcontainer").dialog('open');
});
});
button
<input type="button" ID="search_data" runat="server" class="sear_btn" value="Search Data" OnServerClick="search_data_Click" />
now when i remove this OnServerClick="search_data_Click" from button then pop up display and grid view not display and when i add this then pop up not appear grid view display
whereas i want both on one button
any solution?
Just trigger your search_data_Click Function after Dialog show code in script.
$("#search_data").click(function () {
$("#divcontainer").dialog('open');
search_data_Click();});

Backbone.js listening to events for Map control buttons

I am using Bing maps to display a map on my web page which will be plotting geo-location data on it.
I have added some UI controls directly in my HTML as a generic UI control panel (not all are relevant to MapView):
<div id="navbar" class="navbar-collapse collapse">
<a id="reloadMap" title="Refresh map" class="btn btn-primary" href="#"><span class="glyphicon glyphicon-repeat"></span></a>
<a id="legend" title="Display the Map legend" class="btn btn-primary" href="#"><span class="glyphicon glyphicon-tags"></span></a>
<a id="listView" title="See Engineers in a list" class="btn btn-primary" href="#"><span class="glyphicon glyphicon-list-alt"></span></a>
<a id="mapZoomOut" title="Zoom the map out" class="btn btn-primary" href="#"><span class="glyphicon glyphicon-zoom-out"></span></a>
<a id="mapZoomIn" title="Zoom the map in" class="btn btn-primary" href="#"><span class="glyphicon glyphicon-zoom-in"></span></a>
</div>
Which looks like so in my page:
I created a MapView with events that then calls the Map model to Zoom in or out etc.
However the events hash is not working and I checked the console for my log message but nothing.
define([
'jquery',
'underscore',
'backbone',
'models/mapModel',
'common'
], function ($, _, Backbone, Map, Common)
{
'use strict';
var MapLayer = Backbone.View.extend({
el: '', // the element is set in the model when calling Bing maps
// The DOM events specific to an item.
events: {
'click .mapZoomOut': 'mapZoomOut',
'click .mapZoomIn': 'mapZoomin',
'click .reloadMap': 'initialize'
},
model: null,
/**
#name constructor
#method initialise
**/
initialize: function ()
{
this.model = new Map();
},
/**
Tell the Map model to zoom out after pressing zoomout key
#method mapZoomOut
**/
mapZoomOut: function ()
{
console.log("Zoom out");
this.model.zoomOut();
},
/**
Tell the Map model to zoom in after pressing zoomout key
#method mapZoomIn
**/
mapZoomIn: function ()
{
console.log("Zoom in");
this.model.zoomIn();
},
});
return MapLayer;
});
Have I missed something out?
Two things are missing.
el should be '#navbar' bcz whatever you are writing in events, backbone gonna assign handler on el and then events gonna propagate to selectors.
Since you have added id inside html as unique parameter so selector inside events should be id based.
el: '#navbar'
events: {
'click #mapZoomOut': 'mapZoomOut',
'click #mapZoomIn': 'mapZoomin',
'click #reloadMap': 'initialize'
},