Open.Core.ViewBase.Insert C# (CSharp) Method

Insert() public method

public Insert ( string cssSeletor, InsertMode mode ) : void
cssSeletor string
mode InsertMode
return void
        public void Insert(string cssSeletor, InsertMode mode)
        {
            // Retreive the target element used for the insertion.
            jQueryObject element = jQuery.Select(cssSeletor);
            if (element == null) throw GetInsertException(cssSeletor, "No such element exists");

            // Invoke the pre-method.
            OnBeforeInsert(element, mode);

            switch (mode)
            {
                case InsertMode.Replace:
                    // Perform the insertion.
                    Css.CopyClasses(element, Container);
                    Container.ReplaceAll(cssSeletor);
                    break;

                default: throw GetInsertException(cssSeletor, string.Format("The insert mode '{0}' is not supported.", mode.ToString()));
            }

            // Finish up.
            UpdateLayout();
            OnAfterInsert(mode);
        }