Issue #1584💬 AnsweredOpened November 15, 2018by coder-strange1 reactions

Not getting the Script of Block from editor.getComponents()

Quick answerby artf1

@taufeek6 #1576

Read full answer below ↓

Question

Below is the Component that I'm adding. this.editor.BlockManager.add('dob-mmyy-pii', { id: 'dob-mmyy', label: DOB (MM, YYYY) (PII), category: 'Forms', attributes: {class:'fa fa-birthday-cake'}, content : { content : <div> <label>DOB (Month and Year)</label> <input name='dob' class="form-control"> </div>, script : function(){ $( $(this).find('input[name="dob"]') ).datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', onClose: function(dateText, inst) { console.log("inst",inst) $(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth,...

Answers (3)

artfNovember 19, 2018

@taufeek6 #1576

artfNovember 17, 2018

If the script is a function and you can't serialize it in a JSON. I think, in your case, you need a new custom component type (you're just adding a block) then you'll export only changed properties (the script will be part of the component definition, so you won't need it in the JSON)

coder-strangeNovember 19, 2018

Bingo! that worked perfectly fine but it's letting all of the element to be selected in the block (By directly giving the block html in 'content', content : { content : 'html' } was working fine) so how do I forbid the elements to be selected in a block? For example, in the above image, I don't wan...

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.