Comments (4)
I want the data to be passed without closing the modal , as close event will only work on closing the modal , I want to send data back to parent component without closing the modal
from primeng.
Hi jstechaut,
In my project, when I'm working with Dynamic Dialog, I use the close method to pass data back to the parent. Basically, inside the opened component, I inject the DynamicDialogRef reference. Then, on the close button, I call the close method, passing the data. In the parent component, it is necessary to subscribe to the onClose event.
You can find a sample on the link bellow:
https://primeng.org/dynamicdialog
from primeng.
You can write a small function to have a promise that only resolves once the dialog is closed:
export async function showModalDialogWithRef(dialogService, content, data) {
const dialogRef = dialogService.open(content, {
// your options
data: {
...data,
},
});
return new Promise((resolve, reject) => {
dialogRef.onClose.subscribe((result) => {
resolve(result);
});
});
}
Or you can return the reference in case you need to use it to dynamically close later
export async function showModalDialogWithRef(dialogService, content, data) {
const dialogRef = dialogService.open(content, {
// your options
data: {
...data,
},
});
// Properly bind the context of the dialog so we can close it dynamically
dialogRef.close = dialogRef.close.bind(dialogRef);
return [
new Promise((resolve, reject) => {
dialogRef.onClose.subscribe((result) => {
resolve(result);
});
}),
dialogRef,
] as const;
}
from primeng.
Interesting. Try passing the callback as part of the data
object then, and you can call it from your modal directly.
from primeng.
Related Issues (20)
- tabMenu breaks table virtual scroll calculations
- Primeng Table: Clear the filters which are not applied when filter menu closed by clicking outside the menu
- PrimeNGConfig | Add csp
- Listbox unit test fix
- Fileupload
- InputOtp: Paste function works when readonly set to true
- Menubar, MegaMenu: Submenu doesn't open on mouseover, when using touchscreen notebook with mouse
- Orderlist Unit Test Fix
- InputSwitch Component: Fix unit test
- Table filter: templating filter as Calendar with selectionMode range throws error
- MultiSelect Unit Test Fix
- TreeSelect | lazy support
- Split button: tooltip for the items HOT 1
- Button | Remove wrapper span elements from icon templates
- @bon-vivant
- Hi, this is still an issue in 17.16.1, can you please check? Thanks in advance
- Dropdown: Cannot read properties of null (reading 'classList') HOT 1
- TreeTable Component: fix unit test
- Button Directive | label input type mismatch HOT 1
- FileUpload: Fix unit tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primeng.