Posts

Showing posts from November, 2014

Sweet Summernote

Image
Background If you ever wish to add WYSIWYG functionality to your web project, summernote.js is probably your best bet! It will convert your textarea control to a fully functional WYSIWYG control with ability to gain access to the content of the control in HTML format. Implementation To change a simple textarea control to a WYSIWYG control, $( '#summernote' ).summernote(); To fetch the HTML content of the control: var sHTML = $( '.summernote' ).code(); Wishing you all the best as you try this out.

Using AngularJs $index

Image
Background Today I had a set if divs I created using AngularJs ng-repeat. My challenge was that there was a button in each div that triggered a modal pop-up when clicked. The content of the modal was supposed to be updated from the corresponding element that generated the particular button that was clicked. Hmm... Solution Taking advantage of the ng-click attribute and $index, I added this to the button element ng-click="SetSelected($index)" $index is a powerful reference that allows us to pass the index of the element that generated the current control to a function.  That way, I was able to fetch the correct element from the original array of elements that generated the set of controls!  Isn't Angular sweet?