Issue #1499Opened October 10, 2018by coder-strange0 reactions

[Question] Is it possible to perform dom manipulation through the block's contents script?

Question

Hey! First of all thank you so much to build such a great and versatile tool. Is it possible that I can manipulate the dom elements of the block through block's content script?

Eg.

 editor.BlockManager.add('open-question-2',  {
      id: 'open-question-2',
      label: `Open ended question 2`,

      category: 'Forms',
      attributes: {class:'fa fa-question-circle '},
      droppable: 'form',
      content:{
        content : `
          
        <div  data-id="question-container">
          <label>Question</label>
          <input type="textbox" class="form-control">
        </div>
        `,
        script : function(){
          $("div[data-id='question-container']").find("input").attr("value", "Enter you question here...")
        }

      }
    });

Basically I need a survey kinda block, where user can drop question block and then can enter the question string.

Once again thank you so much.

Answers (3)

coder-strangeOctober 11, 20180 reactions

@artf gjs dom manipulation2

I've added the jquery, in the above image I've added the value attribute to input tag as we can see that in the above image, but that value attribute is not there in the final HTML I'm getting from the editor.

editor.StorageManager.add('local', {
      // New logic for the local storage
      load() {
        // ...
      },
      store(data, clb, clbErr) {
        // ...
        console.log(data['gjs-html'])  //<<<< In this html I'm not getting the **value** tag that I've added thru jquery dom manipulation.

      },
    });
artfOctober 12, 20180 reactions

Use the latest version please

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.