X-editable: How to add an extra attribute to the input box?

x-editable bootstrap 4
x-editable get value
x editable error message
data-pk attribute
editable textarea
x editable checklist
x editable set value jquery
editable popup javascript

I have a link that has x-editable enabled on it with data-type="text".

I want to add an additional attribute to the input field that is created when the item is being edited.

So at the moment x-editable is producing the following input field:

<input type="text" class="form-control input-sm" style="padding-right: 24px;">

And I want to add a pattern attribute, so it would look like (adding pattern attr ):

<input type="text" class="form-control input-sm" style="padding-right: 24px;" pattern="blah">

How can I add this extra attribute?

Note that every click on the x-editable element you can reach the generated input in the popup by using

$('your element').on("click",function(){
  $(this).next().find(".editable-input input").attr("data-pattern","yep 1!")

See below snippet : using inspect you'll see that the pattern attr is present

$(function() {
      $(this).next().find(".editable-input input").attr("data-pattern","yep 1!")
      $(this).next().find(".editable-input input").attr("data-pattern","yep 2!")
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<a href="#" id="username1" data-type="text" data-pk="1" data-title="Enter username">superuser 1</a>
<a href="#" id="username2" data-type="text" data-pk="2" >superuser 2</a>

X-editable :: In-place editing with Twitter Bootstrap , Note to include x-editable after core library (bootstrap, jquery-ui)!. Markup elements that should be editable. Usually it is <A> element with additional data-* attributes will be displayed in input if original field value is empty ( null|​undefined|'' ). X-editable. In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery. This library allows you to create editable elements on your page. It can be used with any engine (bootstrap, jquery-ui, jquery only) and includes both popup and inline modes. Please try out demo to see how it works.

You can set any value using attr method (We don't have addAttr method as we have for class addClass we just need to use element.attr('AttributeName','AttributeValue')).

If you wish to remove the attribute then you may use the below syntax.


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="form-control input-sm" style="padding-right: 24px;">

Angular-xeditable :: Edit in place for AngularJS, For some extra controls (e.g. datepicker) you may need to include angular-ui make element editable via textbox just add editable-text="model.field" attribute. I have a link that has x-editable enabled on it with data-type="text". I want to add an additional attribute to the input field that is created when the item is being edited. So at the moment x-

You can use the .attr() method from jQuery:


How to access attributes value as params in x-editable?, we can also add another parameter with data attribute. so you can set attribute and pass that attribute in your ajax POST, GET, PUT method also. The step Attribute. The input step attribute specifies the legal number intervals for an input field.. Example: if step="3", legal numbers could be -3, 0, 3, 6, etc. Tip: This attribute can be used together with the max and min attributes to create a range of legal values.

custom widget with select · Issue #173 · vitalets/x-editable · GitHub, I was thinking more along the lines of re-using x-editable's own inherit your custom widget from current select and add to template one more input (e.g. type=​text ). I have a text field and a select box and i want to load select options (str) { /* this is mainly for parsing value defined in data-value attribute. The HTML <form> element defines a form that is used to collect user input: An HTML form contains form elements. Form elements are different types of input elements, like: text fields, checkboxes, radio buttons, submit buttons, and more. The <input> element is the most important form element. The <input> element is displayed in several ways

Fix x-editable for Bootstrap 4, form.find('div.editable-input').append(this.input. event event object @param {​Object} params additional params @param {mixed} params. Value that will be displayed in input if original field value is empty (`null|undefined|''`). /how-to-set​-json-format-to-html5-data-attributes-in-the-jquery */ tryParseJson: function(s, safe)  To add custom attributes to objects Select the object or node you want to add attributes to. In the Attribute Editor, select Attributes > Add Attributes, or select Modify > Add Attribute from the main menu bar. Enter a Long Name for the attribute. (Optional) Turn on Override Nice Name and add a non-default nice name for the attribute.

Making content editable, and Firefox-specific HTML editing UI has been deprecated for additional details. How does it work? All you have to do is set the contenteditable attribute on nearly any text (bold, italics, etc), while others insert new elements (like adding a intLink { border: 0; } #toolBar1 select { font-size:10px; } #textBox  Using attributes in a block and creating an annotative block. - Duration: 9:45. Lesliew.cad 6,584 views. AutoCAD Title Block: Insert and Scale to Fit Layout. - Duration: 5:32. CAD Intentions w

  • try look at the documentation api.jquery.com/attr, So basic $(element).attr("attribute","value")
  • @CarstenLøvboAndersen I have no way to access the element though, that I can find. I can give the input a class through the editable constructor, however, this input field doesn't exist until the element is clicked on (converted into an input field by x-editable). So if I did $('.class').attr("pattern", "blah"); then it wouldn't do anything as the input isn't there yet. Correct me if I'm wrong.
  • Cool, that's what I was looking for. Thanks!
  • do comment why negative vote? and explain what is wrong with the answer
  • The reply I have put above has the same issue as your answer, wasn't me that downvoted your answer mind.
  • Not my vote (don't have the rep for it) but I believe the problem is that your answer is basic the same as the comment in the question
  • Okay..@PeterHansen , I haven't seen the comment before i posted my answer