XBL method acts as private method.

Discuss building things with or for the Mozilla Platform.
Post Reply
hammer65
Posts: 2
Joined: May 24th, 2015, 9:35 am

XBL method acts as private method.

Post by hammer65 »

I keep getting a "not a function" error from an XBL binding when called from outside. This element is supposed to contain information about bookmarks in a custom browser application so I commented everything out and tried a simple example and still calling the method throws an error.

This is an XULRunner application (XULRunner 33.1) running on Ubuntu 14.04.

The XBL is here

Code: Select all

<?xml version="1.0"?>
<!DOCTYPE bindings>
<bindings xmlns="http://www.mozilla.org/xbl"
         xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml">
 <binding id="bookmarkitem">
    <implementation>
       <method name="test">
          <![CDATA[
             dump('***** hello *******');
          ]]>
       </method>
    </implementation>
 </binding>
</bindings>

The XUL file

Code: Select all

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<?xml-stylesheet href="bindings.css" type="text/css"?>

<dialog id="add-bookmark" title="Edit My Bookmarks"
            xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        buttons="accept,cancel"
        ondialogaccept="return doOK(event);">

  <vbox id="list">
     
  </vbox>

  <script>
     <![CDATA[
        (function(){
           var list = document.getElementById('list');
           var item = document.createElement('bookmarkitem');
           var data = window.arguments[0];
           var temp;
           for(let i = 0;i < data.length;i++){
              temp = item.cloneNode();
              temp.hello();
              //original method call which caused the error
                                // commented out everything below until I could figure this out
              //temp.setButtonAction();
              /*temp.dbid = data[i].id;
              temp.label = data[i].label);
              dump(temp.label);
              temp.url = data[i].url;
              list.appendChild(temp);*/
           }
        })();
     ]]>
  </script>
</dialog>

The CSS binding is below although the action binding (which I commented out and did not post) had content which was visible when this code was run so it's not like it isn't linking to the binding.

Code: Select all

bookmarkitem{
   -moz-binding: url("chrome://nameofmyapp/content/bindings/bookmark.xbl#bookmarkitem");
}
User avatar
LoudNoise
New Member
Posts: 39900
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Re: XBL method acts as private method.

Post by LoudNoise »

Are you creating an extensions?
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
hammer65
Posts: 2
Joined: May 24th, 2015, 9:35 am

Re: XBL method acts as private method.

Post by hammer65 »

LoudNoise wrote:Are you creating an extensions?


No this is actually a XULRunner application. I was able to get the bound object to work just fine in the main window but the minute I put it in a dialog the methods won't work. The content inside the binding is there and if I click on a button inside the binding which triggers a method in the binding it works. But I cannot access that method using a reference to the element.
Post Reply