views:

1183

answers:

2

I've been trying to create my own firefox toolbar with commands that will open and close a modal dialog using either jqModal or nyroModal. In both cases the act of opening the dialog causes errors and I can't find anything out there as to why modals would break.

Browser: Firefox 3.0.11 JQuery: v1.3.2 jqModal: r14 nyroModal: 1.5.0

Sample XUL: `

<!-- required JQuery dependency -->
<!--script src="chrome://jqmtoolbar/content/jquery.js" /-->
`<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" />
<!-- load main library -->
<script src="chrome://jqmtoolbar/content/jquery.nyroModal-1.5.0.pack.js" type="application/x-javascript" />
<script src="http://www.nopuck4you.com/gooble/jqModal-dev.js" type="application/x-javascript" />
<script src="chrome://jqmtoolbar/content/jqm.js" type="application/x-javascript" />


<toolbox id="navigator-toolbox">

    <toolbar id="modal-toolbar" toolbarname="modal test toolbarx" accesskey="G"
             class="chromeclass-toolbar" context="toolbar-context-menu"
             hidden="false" persist="hidden">


        <toolbarbutton id="gb-debug-jqmShow" tooltiptext="Show Modal"
                       label="Show Modal" oncommand="jqmShowModal(event)" />

        <toolbarbutton id="gb-debug-jqmHide" tooltiptext="Hide Modal"
                       label="Hide Modal" oncommand="jqmHideModal(event)" />            
        <toolbarspring/>
        <toolbarseparator/>
        <toolbarbutton id="gb-debug-nyroShow" tooltiptext="Show Modal"
                       label="Show Modal" oncommand="nyroShowModal(event)" />

        <toolbarbutton id="gb-debug-nyroHide" tooltiptext="Hide Modal"
                       label="Hide Modal" oncommand="nyroHideModal(event)" />
        <toolbarspring/>


    </toolbar>
</toolbox>

`

Sample jqm.js file: ` function jqmShowModal(e) { //loadPageHeadElements(); var body = $(content.document).find("BODY"); if(body.find("#jqmModal").length == 0) body.prepend("Hello jqModal!"); var jq = $("#jqmModal", content.document);

jq.jqm({
   //set JQ modal parameters
    ajax: "http://www.google.com",
    modal: true,
    onLoad: choke
});


$("#jqmModal").jqmShow();


//$("#goobModal", content.document).jqmShow();

}

function nyroShowModal(e) {

//loadPageHeadElements();
var body = $(content.document).find("BODY");
if(body.find("#nyroModal").length == 0) body.prepend("<div id=\"nyroModal\">Hello Nyro Modal!</div>");
var nym = $("#nyroModal", content.document);

nym.nyroModalManual({url: 'http://www.google.com'});
//nym.nyroModalManual({content: '<div>Hello from the test toolbar!</div>'});

}

function choke(e) { alert('choke!'); } `

A: 

What if I want to display the modal manually?

Originally it would be:

$.nyroModalManual({ bgColor: 'black', content: "test", title: "title" });

If it's inside the XUL, it causes some errors. Thanks!

Paul
A: 

Looks like the only way to handle this is through the Toolbar Panel object instead of modal windows.

nopuck4you