/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ var tags = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), queryTokenizer: Bloodhound.tokenizers.whitespace, prefetch: { url: '/tags/getTags', filter: function (list) { tdata = $.map(list, function (tag,key) { return {id: key, name: tag}; }); return tdata; } } }); tags.initialize(); $('#deal-form').cloneya({ minimum: 1, maximum: 5, cloneThis: '.toclone', valueClone: false, dataClone: false, deepClone: false, cloneButton: '.col-md-12 .clone', deleteButton: '.col-md-12 .delete', clonePosition: 'after', serializeIndex: true, ignore: 'div.notToClone,.tags_wrap .bootstrap-tagsinput', preserveChildCount: true }).on('after_append.cloneya', function (event, toclone, newclone) { var dealId = newclone.attr('id'); clearForm(dealId); $("#" + dealId + " .link").typeWatch({ callback: function () { perFormFetchItem(dealId); }, wait: 750, highlight: true, allowSubmit: false, captureLength: 2 }); $("#" + dealId + " .tags").tagsinput(); $(".dealPrice").text((parseInt($(".dealPrice").text()) + parseInt(1)).toFixed(2)); }).on('remove.cloneya', function (event, clone) { $(".dealPrice").text((parseInt($(".dealPrice").text()) - parseInt(1)).toFixed(2)); }); $(".link").typeWatch({ callback: function () { perFormFetchItem('deal0'); }, wait: 750, highlight: true, allowSubmit: false, captureLength: 2 }); //$("#tags").tagsinput({ // typeaheadjs: { // name: 'tags', // displayKey: 'name', // valueKey: 'name', // source: tags.ttAdapter() // } //}); $("#searchtags").tagsinput({ typeaheadjs: { name: 'tags', displayKey: 'name', valueKey: 'name', //valueKey: 'id', source: tags.ttAdapter() } });