jquery-bootstrap-scripting icon indicating copy to clipboard operation
jquery-bootstrap-scripting copied to clipboard

Ajax links in modal-footer

Open corpulent opened this issue 12 years ago • 3 comments

Hi, I am trying to add an ajaxed link to the modal-footer to return the user to previous page of the flow. Like so:

<!DOCTYPE html>
<html>
    <head>
        <title>Step 2</title>
    </head>
    <body>
        <h1>Step 2</h1>

        <form class="ajax" method="get" action="/third-page">
            <input type="hidden" name="nothing" value="to-see" />

            <div class="form-actions">
                <a class="btn close-dialog" href="#">Close</a>
                <a class="btn btn-success ajax" href="/first-page">Previous</a>
                <input type="submit" value="Next" class="primary btn-success" />
            </div>
        </form>
    </body>
</html>

However, its not executing the bound click event of the 'Previous' button, it redirects the whole page instead. Should I be using another element to get the previous page? Like a button?

My quick fix for this is to check if there is an event bound to the button or link in modal-footer like so:

Replace https://github.com/Nikku/jquery-bootstrap-scripting/blob/master/lib/jquery.dialog2.js#L208

with

var events = button.data('events');

if (typeof events === 'undefined') {
    if (button.is("a")) { window.location = button[0].href }
}

What do you guys think? Should I also check for click event as well? This fix is working for me.

corpulent avatar Dec 04 '12 18:12 corpulent

I would say the shown code line is a bug. Instead of monkeypatching the link behavior it should trigger the links click functionality.

If i find the time, I will write a patch for that.

nikku avatar Dec 04 '12 21:12 nikku

I totally agree that my 'fix' is a bug, I just wanted to point out that there is an event bound to the link. Looking forward to your patch.

corpulent avatar Dec 04 '12 21:12 corpulent

Well, not only your fix but also my original implementation.

nikku avatar Dec 04 '12 22:12 nikku