Localizing methods for jQuery append prepend wrap parent-Collection of common programming errors

So I am serializing some options in WordPress and then localizing them to be used in my jQuery script, however what I am trying to do next isn’t working.

jQuery('.advert')+ lu_ban_object.method +('Hello World')

So in my db I’ve got some values serialized; following is the data that is being localized to used as method chosen by the user

s:6:”method”;s:5:”.wrap”;}

Essentially what it should do is;

jQuery('.advert').wrap('Hello World')

The user can also append, prepend, wrap, etc but it is just not working, the methods are being localized and serialized so it should work, but it isnt. I have tried the following as well;

jQuery('.advert')lu_ban_object.method('Hello World')
jQuery('.advert')jQuery(lu_ban_object.method)('Hello World')

Is just not working…. anyone know how to solve this. or am I doing it the wrong way? I just have a list in the settings page and each has a value for a different method such as;


        Append
        Prepend
        Wrap
        Parent

update: var dump

array (size=4)
  'title' => string 'My custom title' (length=15)
  'msg' => string 'My message' (length=10)
  'image' => string 'http://i.imgur.com/3tPjx4l.png' (length=30)
  'method' => string '.prepend' (length=8)

I tried the bracket solution but still nothing, jQuery('.advert')[lu_ban_object.method]("Hello World") I am getting the following error: Uncaught TypeError: Object [object Object] has no method '.prepend' So I added the plus symbols and the message went away but the div was still not being added to the page +[lu_ban_object.method]+

following is my localized data that is being printed in the header


/*  */

  1. If lu_ban_object.method equals the string wrap, and you’d like to use that string to call jQuery’s wrap() method, you’d use bracket notation :

    jQuery(function($) {
        $('.advert')[lu_ban_object.method]('Hello World');
    });
    

Originally posted 2013-11-23 09:50:41.