[mochikit] Re: How to automatically init start a Draggable object?
Kevin Kaiser wrote: Assuming you MochiKit.Signal.connect() an event to an element, how do you then programmatically create the custom event object, set its parameters and then use it to signal the DOM element via MochiKit.Signal.signal() to fire the event and pass the custom event object to the connect()'d function? I think you take the problem from the wrong side. Drag an item without the mouse is not dragging, it's just moving. I'd try with Visual.Move. -- Thomas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] ColorPicker using MochiKit
Hi all, I have created a ColorPicker using pure MochiKit. It turned out fine. I am so surprise with ease to use MochiKit. I am completely newbie to JS and MochiKit but when I start with MochiKit I found my self writing like pro. Great documentation helped me to resolve each problem I faced. Both script and example are available at http://www.agrawalinfotech.com/Resources/tabid/57/Default.aspx I request JS pros to look at my script and help me to get it more optimized and perfect. One problem I like to share with everyone. I had code like OC.Controls.ColorPicker = { /// lots of code here // I think these are kind of statics register: function() { //register code here }, unregister: function() { //UnRegister code here } }; OC.Controls.ColorPicker = function(imgId, txtId) { this.__init__(imgId, txtId); }; OC.Controls.ColorPicker.prototype = { __init__ : function(imgId, txtId) { OC.Controls.ColorPicker.register(this); /// this is not available } }; As you can see in above code I am not able to call OC.Controls.ColorPicker.register(this) form __init__ method in ColorPicker.prototype. I am not able to resolve this issue. However I renamed top static method code namespace with OC.Controls.ColorPickerStatic and used OC.Controls.ColorPickerStatic.register(this), and now it is working fine I am not sure what cause this issue. Please help me to understand this so I can write things much better next time. Thanks in advance, and specially for creating MochiKit. Ashish Agrawal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: ColorPicker using MochiKit
On 11/6/06, Ashish Agrawal [EMAIL PROTECTED] wrote: Hi all, I have created a ColorPicker using pure MochiKit. It turned out fine. I am so surprise with ease to use MochiKit. I am completely newbie to JS and MochiKit but when I start with MochiKit I found my self writing like pro. Great documentation helped me to resolve each problem I faced. Both script and example are available at http://www.agrawalinfotech.com/Resources/tabid/57/Default.aspx I request JS pros to look at my script and help me to get it more optimized and perfect. One problem I like to share with everyone. I had code like OC.Controls.ColorPicker = { /// lots of code here // I think these are kind of statics register: function() { //register code here }, unregister: function() { //UnRegister code here } }; OC.Controls.ColorPicker = function(imgId, txtId) { this.__init__(imgId, txtId); }; OC.Controls.ColorPicker.prototype = { __init__ : function(imgId, txtId) { OC.Controls.ColorPicker.register(this); /// this is not available } }; As you can see in above code I am not able to call OC.Controls.ColorPicker.register(this) form __init__ method in ColorPicker.prototype. I am not able to resolve this issue. However I renamed top static method code namespace with OC.Controls.ColorPickerStatic and used OC.Controls.ColorPickerStatic.register(this), and now it is working fine I am not sure what cause this issue. Please help me to understand this so I can write things much better next time. That code will work perfectly fine, if you add arguments to register and unregister. The problem you experienced must be elsewhere, it doesn't exist in the example you've posted. -bob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: ColorPicker using MochiKit
Yeah, I see the code... but your question didn't make any sense. The code you posted would work fine. I think you'll have to phrase your question differently -- e.g. by posting code that *actually* doesn't do what you expect. I will post a another sample code to illustrate my problem. The only suggestion I really have for the code (at a glance) is that you should be consistent about using fully qualified MochiKit names. In a bunch of places you're using the short ones (appendChildNodes), and other places you're using the long ones (MochiKit.Signal.disconnect). It's kinda misleading. Yeah, I will update this. This really confusing for other ppl. Also the code would be more readable if you didn't mix tabs and spaces. Firefox's default tab stop isn't the same as what you wrote it with. Using spaces everywhere is generally best. Most text editors can be configured to expand tabs (soft tabs). Was not knowing such issue, I will update script to use Spaces instead of tabs. Thanks Bob for your suggestion, I will try to post a sample with exactly problem I am facing with OOP type approach in JS. Many thanks for your above suggestions, this will really help me to write some quality JS. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: ColorPicker using MochiKit
Sample code to illustrate my Class problems : if(!OC) var OC = {}; if(!OC.Controls) OC.Controls = {}; OC.Controls.ErrorSample = { errorObjects : [], register: function(errorObject) { this.errorObjects.push(errorObject); }, unregister: function() { this.errorObjects.pop(); } }; OC.Controls.ErrorSample = function(name) { this.__init__(name); }; OC.Controls.ErrorSample.prototype = { __init__ : function(name) { this.controlName = name; //This line generate error; OC.Controls.ErrorSample.register(this); //If I adjust above code with // OC.Controls.ErrorSample1.register(this); // also update above class code to use ErrorSample1 as name } } please copy test above code and you will see error at OC.Controls.ErrorSample.register(this); line. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: ColorPicker using MochiKit
On 11/6/06, Ashish Agrawal [EMAIL PROTECTED] wrote: Sample code to illustrate my Class problems : if(!OC) var OC = {}; if(!OC.Controls) OC.Controls = {}; OC.Controls.ErrorSample = { errorObjects : [], register: function(errorObject) { this.errorObjects.push(errorObject); }, unregister: function() { this.errorObjects.pop(); } }; OC.Controls.ErrorSample = function(name) { this.__init__(name); }; OC.Controls.ErrorSample.prototype = { __init__ : function(name) { this.controlName = name; //This line generate error; OC.Controls.ErrorSample.register(this); //If I adjust above code with // OC.Controls.ErrorSample1.register(this); // also update above class code to use ErrorSample1 as name } } Ok, I see the problem now. You're replacing the ErrorSample object with a function. To do what you want you need something like this: OC.Controls.ErrorSample = function(name) { ; }; OC.Controls.ErrorSample.register = function (object) { ...; }; OC.Controls.ErrorSample.unregister = function () { ...; }; OC.Controls.ErrorSample.prototype = { ...; }; Normally I would write it like this: OC.Controls.ErrorSample = function (name) { ...; }; MochiKit.Base.update(OC.Controls.ErrorSample, { register: function (name) { ...; }, unregister: function () { ...; } }); MochiKit.Base.update(OC.Controls.ErrorSample.prototype, { __init__: function (name) { ...; } }); -bob -bob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---