Rusty Worley
Rusty Worley

Reputation: 11

jquery modal window now opening onclick

Need help! I am trying to open MWO form (../forms/mwo.php) in a modal window after a onclick event. When i click the button i get nothing...not even errors.

<a  id="newMWO" name="newMWO"  data-role="button" data-inline="true" target="_blank" onclick=getWOCnt()>
    New Work Order
</a>

<div id="mwoForm" title="MWO Form"></div>


$(function ()
            {               
                $(".newMWO").on('click', (function (event)
                {
                    event.preventDefault();

                    var loadVars=(encodeURI("../forms/MWO.php?a=<?php echo $_REQUEST['a']?>"));
                    var dialogName= $("#mwoForm").load(loadLVars);

                    $(dialogName).dialog({
                        autoOpen: false,
                        resizable: true,
                        modal: true,
                        bigframe: true,
                        height: 600,
                        width: 1000,
                        overflow: scroll,
                        resizable: true,
                        title: "MWO New Work Order"
                    });

                    dialogName.dialog('open');
                    return false;                                
                }));
            });

Upvotes: 1

Views: 848

Answers (2)

Rohan Kumar
Rohan Kumar

Reputation: 40639

Use # in place of . in your anchor tag selector

like $("#newMWO") in place of $(".newMWO")

or add class to your anchor tag

<a  id="newMWO" name="newMWO" class="newMWO" data-role="button" 
     data-inline="true" target="_blank" onclick=getWOCnt()>
    New Work Order
</a>

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388316

Your selector $(".newMWO") is wrong it should be $("#newMWO"). newMWO is not a class attribute value, it is the id of the element, so you need to use id-selector instead of class-selector

$(function() {
    $(".newMWO").on('click', function(event) {
        event.preventDefault();

        var loadVars = (encodeURI("../forms/MWO.php?a=<?php echo $_REQUEST['a']?>"));
        var dialogName = $("#mwoForm").load(loadLVars);

        $(dialogName).dialog({
            autoOpen : false,
            resizable : true,
            modal : true,
            bigframe : true,
            height : 600,
            width : 1000,
            overflow : scroll,
            resizable : true,
            title : "MWO New Work Order"
        });

        dialogName.dialog('open');
        return false;
    });
});

Upvotes: 0

Related Questions