Giter Site home page Giter Site logo

Comments (6)

t4t5 avatar t4t5 commented on July 17, 2024

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.

pomartel avatar pomartel commented on July 17, 2024

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.

alkrauss48 avatar alkrauss48 commented on July 17, 2024

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.

zzarcon avatar zzarcon commented on July 17, 2024

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.

pomartel avatar pomartel commented on July 17, 2024

@zzarcon yes, I think your implementation is better than mine. Let's hope it gets merged!

from sweetalert.

zzarcon avatar zzarcon commented on July 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.