0
var $butt = $('<input/>').attr({
    type: 'button',
    value: data.styleData,
    id: butnId,
    data - bind: event: {
        click: $parent.submitPopUp
    }
});

it shows an error

palaѕн
  • 72,112
  • 17
  • 116
  • 136
hemanth
  • 35
  • 1
  • 2
  • 11

2 Answers2

1

I think you can't use data - bind directly. It's not valid variable name or attribute name because of the space

but you can do instead :

var $butt = $('<input/>').attr({
    type: 'button',
    value: "button",
    id: "btnId",
    "data-bind": 'event: {click: $parent.submitPopUp}'
});

Kindly check this

Community
  • 1
  • 1
ebram khalil
  • 8,252
  • 7
  • 42
  • 60
1

You are using attr in a wrong way You should try this,

$(function(){
  var butt = $('<input/>',{
      type: 'button',
      value: "button",
      id: "btnId",
      "data-bind": 'event: {click: $parent.submitPopUp}'
   }).appendTo('body');
});

Fiddle http://jsfiddle.net/JAGLu/

Read Best way to add DOM elements with jQuery

Community
  • 1
  • 1
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106