JQUERY UI Portlets (Add a portlet dynamically)

Using Jquery Portlets in the standard 3 - column configuration #col1 #col2 #col3

I would like to add a button that adds another portlet to the selected column:-
using...
<button>Add to column one</button>
with a function:-

$("button").click(function(){
            
            $('.addspace').replaceWith('<div class="portlet" id="portletname1">' +
            '<div class="portlet-header">wwwwwwwwwwwwwwwwwww</div>' +
            '<div class="portlet-content">test</div>' +
            '</div>'
            );

Works and replaces the dummy <div class="addsapce"> (see below) but does NOT include any CSS settings or actual portlet encasement.

Is there an easier way to add portlets dynamically or by button action and one that actually works?

We use:

**** Javascript *****

$( ".portlet" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
            .find( ".portlet-header" )
            .addClass( "ui-widget-header ui-corner-all" )
            .prepend( "<span class='ui-icon ui-icon-closethick'></span>")
            .end()
            .find( ".portlet-content" );

** HTML ***

<div class="column" id="col1">

        <div class="portlet" id="feeds">
                <div class="portlet-header">Feeds</div>

                <div class="portlet-content">Lorem ipsum dolor sit amet,
consectetuer adipiscing elit</div>
        </div>

        <div class="portlet" id="news">
                <div class="portlet-header">News</div>
                <div class="portlet-content">Lorem ipsum dolor sit amet</div>
        </div>

      <div class="addspace1" >

      </div>

</div>
DexterstevensAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DexterstevensAuthor Commented:
JQUERY Portlets is part of the SORTABLE module
Shinesh PremrajanEngineering ManagerCommented:
$('.addspace').append('<div class="portlet-header">wwwwwwwwwwwwwwwwwww</div>' +
            '<div class="portlet-content">test</div>' +
            '</div>').addClass("portlet").removeClass("addspace");

Add this in the click function.

Hope this helps


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.