script error (_add_item_select)

edited September 2017 in Technical questions

Below code runs fine, but when click for delete of contact it returns a error on _add_item_select function. var item = undefined

what am i doing wrong ?

var data = [
    {"id":1,"DDCIDX":26253,"DDCMAIL":"reception <reception@vanguardlogistics.be>"},
    {"id":2,"DDCIDX":26254,"DDCMAIL":"stefan <stefan.vermeulen@vanguardlogistics.be>"}
    ];
var contact = {
    view:"window", modal:true, id:"contact-win", left:320, top:290, width:780, css:"bradius",
    head:{
        view:"toolbar", margin:-4, cols:[
            {view:"label", label: "Contacts", align:"center"},
            { view:"icon", icon:"times-circle",
                click:"$$('contact-win').hide();"}
        ]
    },
    body:{
        rows:[{
        view:'datatable',
        id:'plda_contact',
        height: 200,
        select: true,
        editable: false,
        scrollY: true,
        scrollX:false,
        columns: [
            {id: "del", header: "", width: 100, hidden:true},
            {id: "DDCIDX", header: "", hidden:true},
            {id: "DDCTYP", header: "", hidden:true},
            {id: "DDCMAIL", header: "e-mail", width: 730, fillspace:true},
            {id:"trash", header:"", width:30, template:"{common.trashIcon()}"}
        ], onClick: {
                "fa-trash": function(e, id) {
                    $$('plda_contact').remove(id.row);
                }
            }},
            {
            view:"form", id:"contact_form",
            elements:[
                {view:"layout", id:'contact_layout', margin: 4, cols:[
                  {view:"text",  label:"e-mail", name:"DDCHI", id:"DDCHI", loaded:0, contactneeded: 1, labelWidth: 60},
                    {view:"button", label:"Add", type:"form", width:60, click:function() {
                   }
                    }
                ]}
            ],
            rules:{"DDCHI": webix.rules.isEmail}
        }
        ]
    }
};
    webix.ready(function () {
      webix.ui(contact);
      $$('plda_contact').parse(data);
      $$('contact-win').show();
    });
Tagged:

Comments

  • The onClick fires earlier than selection/itemClick handlers, so the script will throw an error, as it is unable to work with a non-existing row.
    To avoid any issues, prevent the further processing by returning false:

    onClick: {
       "fa-trash": function(e, id) {
           $$('plda_contact').remove(id.row);
           return false;
       }
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion