I am developing a jQuery widget in jQueryUI factory widgets that need a function that should be passed to it as a parameter. the problem is that the function passed is launched every time a new instance of the widget is created. here is my code:
$(function(){
$('a').addrow({
inputs:[
{
name:'loo',
type:'submit',
click:function(){alert(1);}
}
]
})
})
$.widget('namespace.addrow', {
options: {
inputs:[]
},
_create: function () {
alert(2);
}
})
as you can see, I passed an anonymous function in an array inputs, and it alert(1);executes correctly when the document is ready.
user2827772
source
share