So I have a table and I have to populate a modal using the data from the Table I have written following code
Javascript
var tableHeaders = JSON.parse('["name","phone","email","message"]');
console.log(tableHeaders) ;
$('.openUpdateform').on('click', function() {
$('#callApi').hide();
$('#updateData').show();
tr = $(this).parent().parent().parent().parent();
console.log(tr.children());
for (var i = 1; i < tr.children().length - 1; i++) {
j = i - 1;
$('#' + tableHeaders[j]).val(tr.children()[i].outerText);
}
$('#data_row_id').val($(this).data('row_id'));
$('#createWF').modal();
})
JSFIDDLE
SO the above code works perfectly on Chrome but not in Mozilla Firefox any suggestions appreciated .
Not Working
Means from the Action DropDown if you select the Edit Data option it will open a popup and that popup gets filled in Chrome but not Firefox.
Thanks
the problem is that Firefox doesn't support Node.outerText. Use Node.innerText instead and you'll be all right.
You must use "innerText" instead of "outerText".
https://developer.mozilla.org/es/docs/Web/API/HTMLElement/outerText
Related
When I run this code it reads only index 0 what is wrong?
Javascript:
function openTabs()
{
var data = document.getElementById('excelData').value;
var rows = data.split("\n");
for(var i = 0; i < rows.length; i++)
{
window.open('http://www.google.com/search?q=' + rows[i]);
}
}
HTML:
<textarea id = "excelData" name="excel_data" style="width:300px;height:580px;"></textarea><br>
<input type="button" onclick="openTabs()" value="Open Tabs"/>
There is nothing wrong with neither the code before the loop nor the loop itself. I suspect the browser you are using is blocking you from opening som many windows.
You can verify this by changing the line to something else, for example console.log(rows[i]); and see if that outputs more than the first element in the index.
This depends on the browser. If you are using Chrome, it will block opening multiple windows at the same instant. To allow this, in the address bar, click Pop-ups blocked and select "Always show pop-ups from [site]"
You can try by setting a the name property of the window.open method. ALong with that you may need to allow pop up from the browser.
Here is snippet to add name property to window.open
function openTabs() {
var data = document.getElementById('excelData').value;
var rows = data.split("\n");
for (var i = 0; i < rows.length; i++) {
// second parameter is the name
window.open('http://www.google.com/search?q=' + rows[i],'newWindow'+i);
}
}
DEMO
Allow popup from the browser option
I used this function to create a hint button after the input box.
function hint_draw() {
var inputs = document.querySelectorAll("#formIDHere input[name='name[]']");
for(i=0; i < inputs.length; i++) {
var button = document.createElement("a");
button.innerHTML = "<img src='image/hint.jpg' width='32' height='32'></img>";
button.href = "javascript:hint("+ i +")";
$(button).insertAfter(inputs[i]);
}
}
This code works fine in Chrome, but it doesn't work in Firefox. Why?
EDIT: Really, this script works fine.
Maybe I have problems with the other things.
The best answer is jQuery: insertAfter() doesn't work on Firefox but it's a comment so I can't accept it.
Bye!
http://jsfiddle.net/hfj3cs08/6/ this fiddle works fine.
May be your firefox version is not supporting the tag.
Change the button.innerHTML like the following
button.innerHTML = "<img src='image/hint.jpg' width='32' height='32'/>";
I think IE hates me. Everything I do in other browsers works, but IE 11, no! It is failing. I'm guessing it's me and not the browser.
I have a <select> list on my web page, and I'm trying to bind the <option> dynamically.
So far, it works great in Firefox and Chrome, but not in IE. There is no error in the IE Development tools (F12) so I'm lost as to why it refuses to work.
JSFIDDLE
HTML
<select id="MyList">
</select>
Javascript
$(function() {
var myItems=[];
myItems.push({"All":"Hello"});
myItems.push({"One":"And More"});
myItems.push({"Two":"Lots More"});
for (i = 0; i< myItems.length;i++) {
for (item in myItems[i]) {
var x = myItems[i][item]; //for my testing
var y = myItems[item]; //for my testing
$("#MyList").append("<option>" + item + "</option>");
}
}
});
If you try the fiddle in FF or Chrome, all good. The select list populates with All, One and Two.
Short of a gift or even some form of sacrifice to the IE elves, what do I need to do to make IE happy with me?
This is bizarre. When I run that fiddle in the IE I have handy (IE9), I get an "access denied" error and jQuery isn't loaded. If I change the fiddle to use 1.11.0 rather than 1.10.1, I don't get that error and the script runs.
There are a couple of issues with the code, primarily undeclared variables (your code was falling prey to The Horror of Implicit Globals); here's an updated fiddle with:
Variable declarations
Using jQuery 1.11.0
Using the "no wrap - body" option rather than "onload", since you're using the ready event
Here's the code:
$(function() {
var myItems=[];
myItems.push({"All":"Hello"});
myItems.push({"One":"And More"});
myItems.push({"Two":"Lots More"});
var i, item;
for (i = 0; i< myItems.length;i++) {
for (item in myItems[i]) {
var x = myItems[i][item];
var y = myItems[item];
$("#MyList").append("<option>" + item + "</option>");
}
}
});
Separately, though, to be compatible with a wider range of browsers, you might want to use the Option constructor and the add method of the options list rather than appending a DOM element; some older browsers prefer it. That looks like this: Fiddle
// Before the loop...
var options = $("#MyList")[0].options;
// ...in the loop
options.add(new Option(item));
JSFIDDLE
var sel = $("#MyList");
sel.empty();
for (var i = 0; i< myItems.length;i++) {
for (var item in myItems[i]) {
var x = myItems[i][item];
var y = item;
console.log(x);
console.log(y);
sel.append('<option value="' + x + '">' + y + '</option>');
}
}
As already mentioned by # T.J.Crowder in IE 10 jquery1.10.1 is not working and updating the jquery version to later it started to work;
Try this
$(function() {
var myItems=[];
myItems.push({"All":"Hello"});
myItems.push({"One":"And More"});
myItems.push({"Two":"Lots More"});
for (i = 0; i< myItems.length;i++) {
for (item in myItems[i]) {
var x = myItems[i][item];
$('#MyList')
.append($("<option></option>")
.attr("value",x)
.text(item));
}
}
});
I have this html code for my button:
Click
and this javascript code for set display style the button:
function setstyleint()
{
var divArray = document.getElementById('processLink');
divArray.style.display = 'initial';
}
it work in ff and chrome very good.
but in opera and ie(my version is 9) do not work,
is there any help?
best regards.
Try divArray.style.display = '';
insted of divArray.style.display = 'initial';
also commented by epascarello
Iam working in an mvc application and using ckeditor 3.6.2 version. I have used the following code for getting selected html from ckeditor.
CKEDITOR.editor.prototype.getSelectedHtml = function () {
if (CKEDITOR.env.ie) {
this.focus();
selection = this.getSelection();
} else {
selection = this.getSelection();
}
if (selection) {
var bookmarks = selection.createBookmarks(),
range = selection.getRanges()[0],
fragment = range.clone().cloneContents();
selection.selectBookmarks(bookmarks);
var retval = "",
childList = fragment.getChildren(),
childCount = childList.count();
for (var i = 0; i < childCount; i++) {
var child = childList.getItem(i);
console.log(child);
retval += (child.getOuterHtml ?
child.getOuterHtml() : child.getText());
}
return retval;
}
};
I have an issue in chrome browser when I selected a text and call CKEDITOR.instances.editor1.getSelectedHtml().
For example, suppose in my editor there is a content <span style="color:red;">Welcome Note</span>. If I selected "Welcome Note" and call getSelectedHtml() method firefox,safari,IE8 returns "Welcome Note" with span tag, but chrome returns only the text "Welcome Note". If Iam trying to replace the selected content using CKEDITOR.instances.editor1.insertHtml("<div style='font-size:12px'>"+ CKEDITOR.instances.editor1.getSelectedHtml()+"</div>"), in chrome I lost the font color since getSelectedHtml() returns only the selected text. But this works fine with other browsers.
Note : If the content is "Welcome <span
style="color:red;">Note</span>" and the selected word is "Welcome
Note". In this case,this will be correct in chrome and other browsers.
Please suggest a proper solution.
There have been some similar cases that are documented on the CKEDITOR web site. In particular, take a look at this one:
http://cksource.com/forums/viewtopic.php?f=11&t=20202