attachObj not working

When I try to attach an input to a calendar after created it doesnt work (it gives me a js error)

Unfortunately the issue cannot be reconstructed.
Please, make sure that you are using the version 3.0 of dhtmlxCalendar. (This method was added only in the version 3.0 of the product).

While I cannot reproduce exactly what isabeln described, there is definitely a problem with the attachObj() function for the calendar.
I’ve included an HTML page derived from your example page. Since I cannot attach files, I’ll just include it at the bottom of the post.

I changed the calendar setup so that it only initializes one of the 3 inputs. Then, in a second function, I try to use attachObj as described on the API page to add the second input. Then I use the way that is necessary to get it to work to activate the third input.
Using the code suggested in the API doesn’t work.

 function eZ(){
    myCalendar.attachObj('calendar2');//does nothing
    myCalendar.attachObj({'input':document.getElementById('calendar3')});//works
 }

The problem appears to be in your attachObj function. You assign this.i[a]=obj , which presumably is supposed to be the HTML element from the page, but in _attachEventsToObject(), you reference this.i[a].input , so it cannot find the input element.

	this.attachObj = function(obj) {
		if (typeof(obj) == "string") obj = document.getElementById(obj);
		var a = this.uid();
		this.i[a] = obj;
		this._attachEventsToObject(a);
	}
	this._attachEventsToObject = function(a) {
		if (this.i[a].button != null) {
			this.i[a].button._dhtmlxcalendar_uid = a;
			if (window.addEventListener) {
				this.i[a].button.addEventListener("click", that._doOnBtnClick, false);
			} else {
				this.i[a].button.attachEvent("onclick", that._doOnBtnClick);
			}
		} else if (this.i[a].input != null) {
			this.i[a].input._dhtmlxcalendar_uid = a;
			if (window.addEventListener) {
				this.i[a].input.addEventListener("click", that._doOnInpClick, false);
				this.i[a].input.addEventListener("keyup", that._doOnInpKeyUp, false);
			} else {
				this.i[a].input.attachEvent("onclick", that._doOnInpClick);
				this.i[a].input.attachEvent("onkeyup", that._doOnInpKeyUp);
			}
		}
	}

Example for testing

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Attach to input</title>
</head>
<body onload="eY();eZ();">
    <div class="content">
        <div style="display:block;">
            <h3>Attach to input</h3> 
        </div>
        <link rel="stylesheet" type="text/css" href="../../codebase/dhtmlxcalendar.css">
        <link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxcalendar_dhx_skyblue.css">
        <script src="../../codebase/dhtmlxcalendar.js"></script>
        <style>
            #calendar,
            #calendar2,
            #calendar3 {
                border: 1px solid #909090;
                font-family: Tahoma;
                font-size: 12px;
            }
        </style>
        <script>
            var myCalendar;

            function eY() {
                myCalendar = new dhtmlXCalendarObject(["calendar"]);
            }
            function eZ(){
                myCalendar.attachObj('calendar2');
                myCalendar.attachObj({'input':document.getElementById('calendar3')});
            }
        </script>
        <div style="position:relative;height:280px;">
            <input type="text" id="calendar">
            <input type="text" id="calendar2">
            <input type="text" id="calendar3">
        </div>
    </div>
</body>
</html>

For reference, I’m using DHTMLX Calendar version 3.6, build 131108.

Hi

please try attached updates
29.ZIP (54.9 KB)

Thanks! Everything seems to work, but the included files don’t include the recent IE11 hot fix released back on November 14, 2013 (specifically, the version of dhtmlxcommon.js in this bundle no longer recognizes IE11’s funky user agent string correctly).

I only needed to update dhtmlxcalendar.js to get things working, though, so it’s not a big problem.