codepb/jquery-template

[Feature request] pass loaded dom on to success callback

elgs opened this issue · 3 comments

elgs commented

I think it would be useful to pass the loaded dom onto the success callback so that some post load work could be done easier on the dom loaded.

Also I'm hoping if the binding data is an array, each dom could be passed to the success callback respectively. That would be super useful.

I can have a look into this when I get the time

elgs commented

Thanks @codepb. More often I load an array of doms using jquery-template. Passing data is a bit awkward right now. The data-template-bind helps, however, if it's a huge object, it's still awkward. Ideally, I'm hoping I can use $('each_dom_in_array').data('my_data_key', my_data_value). So if each dom in the array could be passed to the success callback for me to have a chance to bind the object using the jQuery data function, that would be extremely great.

elgs commented

@codepb I found all I need is:

afterInsert: function (elem, data) {
    elem.data('my_data', data);
},