Comments (6)
Currently, lines 191-203 in sweet-alert.js are the ones holding the default parameters like this:
var params = {
title: '',
text: '',
type: null,
allowOutsideClick: false,
showCancelButton: false,
closeOnConfirm: true,
confirmButtonText: 'OK',
confirmButtonColor: '#AEDEF4',
cancelButtonText: 'Cancel',
imageUrl: null,
imageSize: null
};
Couldn't you just change this so that it fits your project? I don't think there's a need to add an additional place where you can set the defaults.
from sweetalert.
Yes, I saw that but the params variable is not public so I cannot extend it from the outside. It would be nice if this could be changed the way jQuery UI does it for exemple. You would just have to expose the params hash so it can be extended from outside the plugin.
I can give it a try on a pull request if you feel this is something others could benefit from.
from sweetalert.
I agree with @pomartel, the ability to set default options outside of the plugin file would be cool. Having to edit the lib file makes updates more tedious, and prevents the ability to use a public CDN. Currently I'm just handling it with a function that has default attributes, merges in the custom attributes from the parameters, and calls swal
. It works, but would be cool to have it baked in!
Great plugin, this seriously makes UI much more awesome.
from sweetalert.
Guys what do you think about #139? This PR adds the feature (which I think it's a powerful feature) to set a default user params without changing the source code or exporting some variables to global scope, you just have to call the setDefaults
method.
from sweetalert.
@zzarcon yes, I think your implementation is better than mine. Let's hope it gets merged!
from sweetalert.
@pomartel thanks man! Right now I'm waiting some feedback of @t4t5. I also hope that this will be merged because it's very tedious to pass the defaults parameters for each new alert :)
from sweetalert.
Related Issues (20)
- Failure to install Sweetalert React package HOT 2
- Avoid serving legacy JavaScript to modern browsers
- Submit button brings sweetalert popup without saving data in the database
- I think it's because you're binding an action to "onsubmit" which will by default redirect from the page you're on. Try removing the `onsubmit=` part in your HTML and add this to your JavaScript instead (using jQuery):
- How to prevent a toast (from sweet alert 2) from being closed HOT 1
- Links?
- Still bounce effect even after setting animation to "false"
- Docs, not just examples HOT 1
- Added support for rtl pages HOT 1
- How to center swal-button HOT 1
- Can not Change Color of Pop-Up button HOT 1
- How do we add javascript objects in the sweetalert text HOT 1
- LMS joomla
- Margin Top problems
- @1234
- Link in text
- Typescript error
- Getting the instance of the current swal to change it's text dynamically?
- Unpkg sweetalert unavalable
- Alert with only an icon and title is missing bottom spacing
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 sweetalert.