Question

I have 2 classes:

$.widget('blueimp.fileupload', {
    a: function  {}
})

$.widget('blueimpUI.fileupload', $.blueimp.fileupload, {
    b: function  {}
})

I want to replace my first two functions with a single class.

Function b works but function a doesn't. Why?

$.widget('blueimpUI.fileupload', $.blueimpUI.fileupload, {
    a: function  {},
    b: function  {}
})
Was it helpful?

Solution

Something like this might work better:

$.widget('blueimpUI.fileupload', {
    fileupload: $.blueimp.fileupload, 
    a: function  {},
    b: function  {}
});

OTHER TIPS

It's not quite clear what you're trying to do but I believe the $.widget method takes two arguments as explained in this documentation:

jquery.ui.widget.js provides a factory method to create widget classes. The signature is $.widget(String name, Options prototype)

Therefore, the code with function b probably does not work due to incorrect syntax.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top