CKEditor Removing attributes in closing tags - ckeditor

I have allowedcontent=true which is working and allowing me to have attributes in my opening tags; however, CKEdtior is still removing the closing tag attributes. I am using the editor to allow modification of simple Handlebars templates that use {{each}} and {{/each}}. The issue comes when using this with a table and wanting to repeat my rows.
For example, I have the following HTML entered into source:
<table>
<tr data-each={{each Person}}">
<td class="col-student-id">{{Identifier}}</td>
<td class="col-name">{{Name}}</td>
</tr data-each="{{/each}}">
</table>
When I click out of source, it removes the attribute on my closing tr tag.
Is there anyway to force CKEditor to not remove this attribute? If not, does anyone know of a way to allows me to use something like this:
<table>
{{each Person}}
<tr>
<td class="col-student-id">{{Identifier}}</td>
<td class="col-name">{{Name}}</td>
</tr>
{{/each}}
</table>
When I try the above example, it is reformatted to be:
<section>{{each Person}} {{/each}}
<table>
<tr>
<td class="col-student-id">{{Identifier}}</td>
<td class="col-name">{{Name}}</td>
</tr>
</table>

Your input source code is invalid - closing tags cannot have attributes in HTML, so CKEditor ignores them. Read more in CKEditor HTML Autocorrection Issue.

Related

PowerApps: Use HTML to modify form display in model-driven apps?

I need to modify the format of a form in a model-driven app to make it more readable/intuitive. Currently, the form looks like this:
I tried to use a web resource to create a simple HTML table with <script> and Xrm.Page.getAttribute() to pull in the relevant fields under the planned and actual columns, but that isn't working. I set the dependencies and assigned it to the proper form element, but no luck. The code that I used is this:
<div>
<table>
<tr>
<td><u>Tasks</u></td>
<td><u>Planned</u></td>
<td><u>Actual</u></td>
</tr>
<tr>
<td>Task 1</td>
<td><script>Xrm.Page.getAttribute("[plannedField_1]")</script></td>
<td><script>Xrm.Page.getAttribute("[actualField_1]")</script></td>
</tr>
<tr>
<td>Task 2</td>
<td><script>Xrm.Page.getAttribute("[plannedField_2]")</script></td>
<td><script>Xrm.Page.getAttribute("[actualField_2]")</script></td>
</tr>
<tr>
<td>Task 3</td>
<td><script>Xrm.Page.getAttribute("[plannedField_3]")</script></td>
<td><script>Xrm.Page.getAttribute("[actualField_3]")</script></td>
</tr>
</table>
</div>
Is this a valid way to modify form output, or is there another/better way to do this that doesn't involve creating an elaborate solution with dynamically scripted HTML?
Uncheck the Display label on the form for one of the controls.

Wijimo 5 AngularJS - ng repeat and Auto Complete Directive issue

I am trying to use the Wijimo Auto Complete Directive inside a ng-repeat and though I can bind successfully to a data source I cannot set the scope for a specific instance - the value selected in 1 directive is set for all instances in the scope.
Its the classic ng-repeat issue when using using repeated input controls.
I am not sure if its the way the wj-auto-complete directive sets which property on the scope.
So this works fine for 1 instance and multiple instances within an ng-repeat (but sets the same value).
<wj-auto-complete
text="selectedHotel"
items-source="limo.hotelData"
placeholder="Hotel"
display-member-path="address"
max-items="50"/>
</div>
<p>{{selectedHotel || json}}</p>
I have tried the following
<div ng-repeat="flight in flights">
<wj-auto-complete
text="flight.from"
items-source="limo.hotelData"
placeholder="Hotel"
display-member-path="address"
max-items="50"/>
</div>
but no joy.
It looks like the text property is what is set with the selected value? Though the property value is a little odd.
Both the ComboBox and AutoComplete control have a "text" property that gets or sets the text currently shown by the control, and also a "selectedValue" property that gets or sets the value that is currently selected. These two often match, except while the user is typing and the incomplete text doesn't match any items in the list of valid choices.
This fiddle shows how using the "selectedValue" property works OK for both the ComboBox and AutoComplete. I hope it's useful:
http://jsfiddle.net/Wijmo5/8p94jo6q/
<table class="table table-condensed">
<thead>
<th>ID</th>
<th>Country</th>
<th>AutoComplete</th>
<th>ComboBox</th>
</thead>
<tbody>
<tr ng-repeat="item in data">
<td>
{{item.id}}
</td>
<td>
{{item.country}}
</td>
<td>
<wj-auto-complete
items-source="countries"
selected-value="item.country"
placeHolder="country"
required="false">
</wj-auto-complete>
</td>
<td>
<wj-combo-box
items-source="countries"
selected-value="item.country"
placeHolder="country"
required="false">
</wj-combo-box>
</td>
</tr>
</tbody>
</table>

Import data from HTML page using feeds importer in drupal

I'm trying to import some data from a HTML page with feeds importer. The context is this:
<table class="tabela">
<tr valign="TOP">
<td class="formulario-legenda">Nome:</td>
<td nowrap="nowrap">
<b>Raul Fernando de Almeida Moreira Vidal</b>
</td>
</tr>
<tr valign="TOP">
<td class="formulario-legenda">Sigla:</td>
<td>
<b>RMV</b>
</td>
</tr>
<tr valign="TOP">
<td class="formulario-legenda">Código:</td>
<td>206415</td>
</tr>
<tr valign="TOP">
<td class="formulario-legenda">Estado:</td>
<td>Ativo</td>
</tr>
</table>
<table>
<tr>
<td class="topo">
<table>
<tr>
<td class="formulario-legenda">Categoria:</td>
<td>Professor Associado</td>
</tr>
<tr>
<td class="formulario-legenda">Carreira:</td>
<td>Pessoal Docente de Universidades</td>
</tr>
<tr>
<td class="formulario-legenda">Grupo profissional:</td>
<td>Docente</td>
</tr>
<tr valign="TOP">
<td class="formulario-legenda">Departamento:</td>
<td>
<a href="uni_geral.unidade_view?pv_unidade=151"
title="Departamento de Engenharia Informática">Departamento de Engenharia Informática</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
I tried with this:
/html/body/div/div/div/div/div/div/div/table/tbody/tr/td/table/tbody/tr[1]/td[2]
but nothing appears. Can someone help me with the right syntax to obtain "Grupo Profissional"?
Quick answer that might work
Considering just the HTML sample you provided (which only has two tables) you can select the text you want using this expression, based on the table's position:
//table[2]//tr[3]/td[1]/text()
This will work in the HTML you pasted above. But it might not work in your actual scenario, since you might have other tables, the table you want to select has no ID and you didn't suggest some invariant text in your code which could be used to anchor the context for the expression. Assuming the initial part of your XPath expression (the div sequence) is correct, you might be able to use:
/html/body/div/div/div/div/div/div/div/table[2]//tr[3]/td[1]/text()
But it's wuite a fragile expression and vulnerable to any changes in the document.
A (possibly) better solution
A better alternative is to look for some identifier you could use. I can only guess, since I don't know your code. In your sample code, I would guess that Codigo and the number following it 206415 might be some identifier. If it is, you could use it to anchor your context. First you select it:
//table[.//td[text()='Código:']/following-sibling::td='206415']
The expression above will select the table which contains a td with the exact text Código: followed by a td containing the exact text 206415. This will create a unique context (considering that the number is an unique identifier). From that context, you can now select the text you want, which is inside the next table (following-sibling::table[1]). This is the context of the second table:
//table[.//td[text()='Código:']/following-sibling::td='206415']/following-sibling::table[1]
And this should select the text you want (Grupo profissional:) which is in the third row tr[3] and first cell/column td[1] of that table:
//table[.//td[text()='Código:']/following-sibling::td='206415']/following-sibling::table[1]//tr[3]/td[1]/text()

selenium webdriver xpath generation

I want to create an xpath for clicking on "run " (4th column) based on the first column value (xyz). the below xpath doesnt work. Can you suggest a better way of writing the xpath.
//table/tbody/tr/td[text()='xyz fix']/parent::tr/td[4]
<div id="main">
<table class="FixedLayout" width="1000px">
<tbody>
<tr></tr>
<tr>
<td class="RowHeight">
xyz
</td>
<td>xyz fix</td>
<td>1125</td>
<td>
Run
</td>
</tr>
<tr>
<td class="RowHeight">
abc
</td>
<td>abc fix</td>
<td>1125</td>
<td>
Run
</td>
</tr>
</tbody>
</table>
</div>
I don't see why your one didn't work. Please clarify what it means "doesn't work". NoSuchElementException? ElementNotVisibleException? Wrong XPath? Not clicking the link or what?
Meanwhile, try the following XPaths (but the issue could be your Selenium code instead of XPath):
Here I assume you want to the <a> link instead of <td>, because you mentioned you want to click it.
Use XPath predicate:
//*[#id='main']//table/tobdy/tr[td[text()='xyz']]/td[4]/a
Use XPath predicate with attribute selector to avoid using index.
//*[#id='main']//table/tobdy/tr[td[text()='xyz']]//a[contains(#href, 'Instance/Create')]
Use .. to get the parent
//*[#id='main']//table/tobdy/tr/td[text()='xyz']/../td[4]/a

Ruby - nokogiri - parse only specific html table

I have a HTML doc to parse and read a bunch of stuff from there. The problem is the html has multiple tables in it, and I am only interested in one table. Plus I want to read only the lines that having some useful content. Here is sample html page, there are two tables with no ID, and I want only the second table and only the lines that are useful to humans.
<HTML>
<BODY>
<TABLE>
<TR>
<TD> I don't want this table </TD></TR>
<TR>
<TD></TD>
<TD> No No No <br></TD>
</TR>
....
</TABLE>
<TABLE>
<TR>
<TD>04/13/2012 22:51 I want this table </TD></TR>
<TR>
<TD></TD>
<TD> First - something there <br></TD>
</TR>
<TR>
<TD>04/13/2012 23:23 Update from xyz</TD></TR>
<TR>
<TD></TD>
<TD>Second - something here <br></TD>
</TR>
</TABLE>
</BODY>
</HTML>
I am trying this code, which is obviously not working. The o/p is not the text I want. It includes both tables, I only want the second table. help!
require 'curb'
require 'nokogiri'
c = Curl::Easy.perform("http://server/cgi-bin/page.cgi?id=123456")
html_doc = Nokogiri::HTML(c.body_str.to_s)
puts html_doc.xpath("//table/tr/td")
Have you tried the xpath of //table[2]/tr/td to get the second table. If you can change the source of the HTML the best solution would be to provide id attributes for your tables.

Resources