AnsweredAssumed Answered

Error: undefined is not a function !

Question asked by yascorp on Apr 15, 2014
I want to display a popUp when I click on my link "Click to test" but I have this error :
"Uncaught TypeError: undefined is not a function"

my js look like:
<javascript>
(function formTest() {
   
   var Dom = YAHOO.util.Dom,
      Event = YAHOO.util.Event;
   
   Alfresco.component.list_news = function list_news_constructor(htmlId) {
      Alfresco.component.list_news.superclass.constructor.call(this, "Alfresco.component.list_news", htmlId);
   this.myDialog = null;
      
   //Register the component   
   Alfresco.util.ComponentManager.register(this);
      
   //Load YUI components
   Alfresco.util.YUILoaderHelper.require([], this.onComponentsLoaded, this);      
   return this;
   };
   
   YAHOO.extend(Alfresco.component.list_news, Alfresco.component.Base,
   {
      option:
      {
               
      },
               
      myDialog: null,
      
      onReady: function list_news_onReady(){
         var configFeedLink = Dom.get(this.id + "-config-link");
         if (configFeedLink) {
         Event.addListener(configFeedLink, "click",this.onConfigListNewsClick, this, true);   
         }
      },
      
      onConfigListNewsClick: function list_news_onConfigListNewsClick(e) {
         
         //folder NEWS nodeRef in "hello" site = "workspace://SpacesStore/30696c74-d03e-40a6-912e-39f2da2b8010"   
         var destination = "workspace://SpacesStore/30696c74-d03e-40a6-912e-39f2da2b8010";
         
         // Intercept before dialog show - not functional yet!
         var doBeforeDialogShow = function my_doBeforeDialogShow(p_form, p_dialog){
            Alfresco.util.populateHTML([ p_dialog.id + "-dialogHeader", "My Header" ]);
         };
         
         var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT +
               "components/form?itemKind={itemKind}&itemId={itemId}&formId={formId}" +
               "&destination={destination}&mode={mode}&submitType={submitType}&showCancelButton=true",
               {
                  itemKind: "type",
                  itemId: "ca:entryFormNews",
                  destination: destination,
                  formId: "custom-metadata",
                  mode: "create",
                  submitType: "json"
               });
         
         // Using Forms Service, so always create new instance
         this.myDialog = new Alfresco.module.SimpleDialog("${args.htmlid}-myDialog");

         this.myDialog.setOptions(
         {
            width: "40em",
            templateUrl: templateUrl,
            actionUrl: null,
            destroyOnHide: true,
            doBeforeDialogShow:
            {
               fn: doBeforeDialogShow,
               scope: this
            },
            onSuccess:
            {
               fn: function myDialog_success(response) {
                  Alfresco.util.PopupManager.displayMessage(
                  {
                     text: "Success!"                  
                  });
                  YAHOO.Bubbling.fire("metadataRefresh", {});
               },
               scope: this
            },

            onFailure:
            {
               fn: function myDialog_failure(response){
                  if (response){
                     Alfresco.util.PopupManager.displayMessage(
                     {
                        text: "Failed to complete task."
                     });
                  } else {
                     Alfresco.util.PopupManager.displayMessage(
                     {
                        text: "Failed to communicate with server…or something"
                     });
                  }
               },
               scope: this
            }
         });
         this.myDialog.setOptions(         
               {            
                   actionUrl: null
               }).show();
         
      }

   });
   
})();
</javascript>


my ftl:
<javascript>
<#assign el=args.htmlid?js_string>

<script type="text/javascript">//<![CDATA[

new Alfresco.component.list_news("${args.htmlid}").setOptions(
   {

   }
   ).setMessages(${messages});

new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");

new Alfresco.widget.DashletTitleBarActions("${args.htmlid?html}").setOptions(
    {
         actions:
         [         
            {
               cssClass: "help",
               bubbleOnClick:
               {
                  message: "${msg("dashlet.help")?js_string}"
               },
               tooltip: "${msg("dashlet.help.tooltip")?js_string}"
            }
         ]
     });    

//]]></script>

<div class="dashlet list_news">
    <div id="${el}-dialogHeader" class="title">${msg("header.list-news")}</div>
      
    <div class="body scrollableList" <#if args.height??>style="height: ${args.height}px;"</#if>>
       <div class="detail-list-item first-item last-item">
          
          <input id="${el}-config-link" type=button name='Test' value="Click to test"/>
                                    
        </div>  
    </div>
</div>
         
</javascript>

my head.ftl:
<javascript>
<#include "../component.head.inc">
<#include "../form/form.get.head.ftl">

<!– list-news  –>
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/dashlets/list-news.css" />
<@script type="text/javascript" src="${page.url.context}/res/components/dashlets/list-news.js"></@script>

<!– file-upload –>
<@script type="text/javascript" src="${page.url.context}/res/components/upload/file-upload.js"></@script>

<!– Simple Dialog –>
<@script type="text/javascript" src="${page.url.context}/res/modules/simple-dialog.js"></@script>

<!– Resize –>
<@script type="text/javascript" src="${page.url.context}/res/yui/resize/resize.js"></@script>
</javascript>

I can see on my share console this result with the error here : —> "new Alfresco.FomrUI

<javascript>
//<![CDATA[
      new Alfresco.FormUI("${args.htmlid}-myDialog-form", "${args.htmlid}-myDialog").setOptions(
      {
         mode: "create",
         enctype: "application/json",
         fields:
         [
            {
               id : "prop_ca_title"
            }
            ,
            {
               id : "prop_ca_category"
            }
            ,
            {
               id : "prop_ca_description"
            }
           
         ],
         fieldConstraints:
         [
            {
               fieldId : "${args.htmlid}-myDialog_prop_ca_title",
               handler : Alfresco.forms.validation.mandatory,
               params : {},
               event : "keyup,propertychange",
               message : …………….
…………………………………..
………………………………….. etc.
   //]]>
</javascript>

I need help, please …
Thanks & Regards


Outcomes