Code Monkey home page Code Monkey logo

Comments (7)

stefangabos avatar stefangabos commented on September 27, 2024

This will sound silly, but I have never needed a vairable like this :)
But this is done simply by having a variable outside your function, like below.

var my_value;
$('#removebuttonstyle i').on('click', function(e) {
    e.preventDefault();
    var t = $.Zebra_Dialog('<strong>Zebra_Dialog</strong>, a small, compact and highly configurable dialog box plugin for jQuery', {
      type: 'question',
      title: 'Custom buttons',
      buttons: [
      {caption: 'Yes'},
      {caption: 'No'}
      ],
      onClose: function(caption) {
        my_value = (caption == 'Yes');
      }
    });
  });

But I don't think you need a variable but rather you need to alter something in DOM, based on the selection in the dialog. If so, the DOM manipulation has to be done in the onClose function

from zebra_dialog.

orso081980 avatar orso081980 commented on September 27, 2024

I kind of solve my problem with a snippet like that:

$('#removebuttonstyle i').on('click', function(e) {
    e.preventDefault();
    var t = $.Zebra_Dialog('<strong>Zebra_Dialog</strong>, a small, compact and highly configurable dialog box plugin for jQuery', {
      type: 'question',
      title: 'Custom buttons',
      buttons: [
      {caption: 'Yes'},
      {caption: 'No'}
      ],
      onClose: function(caption) {
        if (caption == 'Yes') {
          $("#removebuttonstyle i").unbind('click').click()
        } else {
          caption = false;
        }
        return caption;
      }
    });
  });

What do you think about it?

from zebra_dialog.

stefangabos avatar stefangabos commented on September 27, 2024

I first need to know what are you trying to achieve. Are you trying to prevent the dialog from opening again if the user clicked on "Yes" ?

from zebra_dialog.

orso081980 avatar orso081980 commented on September 27, 2024

I'm working in an expressionengine environment with a store plugin on top (espresso). This actually worked but there is a lot of code involved on top of that. As I told you in my first email, I was trying to emulate the confirm javascript function.

This is how my code looks like:

<td class="col-md-1 text-right">
        <button type="submit" id="removebuttonstyle" name="remove_items[{key}]" value="remove">
          <i class="fa fa-minus-circle"></i>
        </button>
      </td>

If I use the confirmation method like that:

// $('#removebuttonstyle i').click(function() {
// console.log("you click!");
// var c = confirm("Are you sure that you want to continue?");
// return c;
// });

It's gonna work the same way it works now with Zebra..

from zebra_dialog.

stefangabos avatar stefangabos commented on September 27, 2024
$('#removebuttonstyle i').on('click', function(e) {
    e.preventDefault();
    $.Zebra_Dialog('<strong>Zebra_Dialog</strong>, a small, compact and highly configurable dialog box plugin for jQuery', {
        type: 'question',
        title: 'Custom buttons',
        buttons: [
            {caption: 'Yes', callback: function() {
                $('your-form').submit();
            }},
            {caption: 'No'}
        ]
    });
});

from zebra_dialog.

stefangabos avatar stefangabos commented on September 27, 2024

I'm not sure if that is working, though...

from zebra_dialog.

orso081980 avatar orso081980 commented on September 27, 2024

Don't worry, mine works! I will try both

from zebra_dialog.

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.