Skip to content

Weld ignores tagets with multiple occurrences  #28

@kallewangstedt

Description

@kallewangstedt

If Weld is used for inserting strings on a page that have targets for insertion that occur more than once it will ignore all but the first. This is seen especially when using Weld as a dynamic translation engine. Often a page can hold the same strings at different locations in the DOM. As of now Weld demands all those targets to be unique and only occur once on each page.

Example (Weld used as jQuery plugin):

<div id="panels">
  <div id="settings">
    <input type="text" name="name" />
    <a class="lang-CANCEL">&nbsp;</a><a class="lang-SUBMIT">&nbsp;</a>
  </div>

  <div id="configuration">
    <label><input type="checkbox" name="visible" /><span class="lang-SHOWNAME">&nbsp;</span></label>
    <a class="lang-CANCEL">&nbsp;</a><a class="lang-SUBMIT">&nbsp;</a>
  </div>
</div>

jQuery(document).ready(function() {
  $('#panels').weld({
      "lang-CANCEL"   : "Avbryt",
      "lang-SUBMIT"   : "OK",
      "lang-SHOWNAME" : "Visa namnet"
  });
});

The code above would leave the two <a>-tags in the configuration div untouched. Since matching of the keys in the Weld object is done using class names, expected would be that Weld inserted the strings on all elements with corresponding classes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions