javascript - How to run jQuery script in Angualrjs -
i use nestable
jquery plugin in project. render nestable plugin , serialization need run jquery script. code is:
var updateoutput = function(e) { var list = e.length ? e : $(e.target), output = list.data('output'); if (window.json) { output.val(window.json.stringify(list.nestable('serialize'))); } else { output.val('json browser support required demo.'); } }; // activate nestable list 1 $('#nestable1').nestable({ group: 1 }) .on('change', updateoutput); updateoutput($('#nestable1').data('output', $('#nestable1-output'))); $('#nestable-menu-1').on('click', function(e) { var target = $(e.target), action = target.data('action'); if (action === 'expand-all') { $('#nestable1').nestable('expandall'); } if (action === 'collapse-all') { $('#nestable1').nestable('collapseall'); } });
<!-- nestable1 start --> <div class="dd" id="nestable1"> <ol class="dd-list"> <li class="dd-item" data-id="1"> <div class="dd-handle">item 1</div> <em class="badge pull-right bg-color-purple">99</em> </li> <li class="dd-item" data-id="2"> <div class="dd-handle"> item 2 <div class="pull-right action-buttons"> <a class="blue" href="#"> <i class=" fa fa-pencil "></i> </a> <a class="red" href="#"> <i class=" fa fa-trash-o "></i> </a> </div> </div> <ol class="dd-list"> <li class="dd-item" data-id="3"><div class="dd-handle">item 3</div></li> <li class="dd-item" data-id="4"> <div class="dd-handle">item 4</div> <ol class="dd-list"> <li class="dd-item" data-id="5"><div class="dd-handle"> item 5 <i class="pull-right fa fa-exclamation-triangle warning"></i> </div></li> <li class="dd-item" data-id="6"><div class="dd-handle">item 6</div></li> </ol> </li> <li class="dd-item" data-id="7"><div class="dd-handle">item 7</div></li> </ol> </li> <li class="dd-item" data-id="8"> <div class="dd-handle">item 8</div> </li> </ol> </div> <!-- nestable1 end -->
how run script in angularjs serialize data.
for me, best way of using jquery (and other javascript) plugins in angular wrap them directives. there nice blog post here:
https://amitgharat.wordpress.com/2013/02/03/an-approach-to-use-jquery-plugins-with-angularjs/
i haven't used nested plugin, see has created agular wrapper it. hope suits needs:
Comments
Post a Comment