0

I have the following code:

        function handlesomeObjDelete(someObj) {
            query('#someObj-delete-link-'+someObj.id).on('click',function(){
                var youSureDlg = new Dialog({
                    title: 'Delete someObj',
                    width:'250px',
                    id:'delete-someObj-dlg'+someObj.id,
                    content:'Are you sure you want to delete this someObj?'
                });

                var yesBtn = new Button({
                    label: 'Yes',
                    type: "button"
                }); 

                var noBtn = new Button({
                    label: 'No',
                    type: "button"
                }); 

                on(yesBtn,'click',function(){
                    request("someUrl/"+someObj.id, {
                        handleAs: "json",
                        type:'delete',
                        headers: {
                          "X-Requested-With": "",
                          "Content-Type": 'application/json; charset=utf-8'
                        }
                    }).then(function(){
                        alert('deleted');
                    });
                });

                on(noBtn,'click',function(){
                    youSureDlg.hide();
                });

                yesBtn.placeAt(youSureDlg);
                noBtn.placeAt(youSureDlg);

                //youSureDlg.startup();
                youSureDlg.show();
            });
        }

And I get the following error:

TypeError: refNode is null
packs[name] = packageInfo;

TypeError: youSureDlg.show is not a function
dojoSniffConfig

I have included dijit.Dialog. If I try to create the Dialog again I get: Tried to register widget with id==someid but that id is already registered

Any idea of what could be wrong?

Thanks.

user3199269
  • 33
  • 1
  • 7

2 Answers2

0

Try doing it this way :

                  if(!youSureDlg){
        var youSureDlg = new Dialog({
            title: 'Title',
            id: "someID",
            content: "",
            style: "width:250pt",
        });
        youSureDlg.show();
                   }

                   else {
                         youSureDlg.show();
                          }

Dialog stands alone and is a seperate Box for itself without binding into another div or something.

Check this out : http://dojotoolkit.org/reference-guide/1.9/dijit/Dialog.html#dijit-dialog

Hope it helps you.

UPDATE1: The Error "Tried to register...." happends, when you want to start a widget that wasn't deleted or unregister after using it. You can handle this by checking if the widget is already there or not. Check my Code - i've updated it.

Also check this older Posts : Dojo dialog close event on X (top-right) and Dojo and unregistering widgets

Regards, Miriam

Community
  • 1
  • 1
MiBrock
  • 1,100
  • 1
  • 11
  • 22
0

It seems that it cannot find your source reference node. This is where the widget code anchors to. The second argument in the new Dialog 'yousuredlg' should be an actual div in your html.

ex.

HTML

<div>
    <div id="yousuredlg"></div>
    <button id="goButton">Go</button>
</div>

JS

require(["dojo", "dijit", "dijit/Dialog", "dojo/on"], function (dojo, dijit, Dialog, on) {
    var youSureDlg;
    on(dojo.byId("goButton"), "click", function () {
        if (!youSureDlg) {
            youSureDlg = new Dialog({
                title: 'Title',
                width: '250px',
                id: 'someid',
                content: 'some content'
            }, 'yousuredlg');
        }
        youSureDlg.show();
    });

})

http://jsfiddle.net/d2sa5/

tik27
  • 2,698
  • 1
  • 16
  • 25