Colorbox and inline html not showing in IE8 - internet-explorer-8

I'm calling inline html in ColorBox and it shows no content in IE8. This can be replicated on Jack Moores own site. Simply goto the demo site, http://www.jacklmoore.com/colorbox/example1/ , then click the second to the last link "Inline HTML". Then click the bottom link to update content ... in IE8 the box shows nothing.
I'm having the same problem, but I'm creating the div collection on the fly as shown below. Its for a check box confirmation. Any suggestions?
$('input[name$=chkApproved]').click(function (e) {
var th = $(this);
if (th.is(':checked')) {
var dialog = '<div">'
+ '<div id="dialog">'
+ '<p style="margin-top: 30px;">'
+ 'Are you sure you want to approve this program?</p>'
+ '<p style="font-size: small;">'
+ '<strong>Note:</strong> This cannot be undone!</p>'
+ '<p style="text-align: center;">'
+ 'Approve'
+ ' '
+ 'Cancel'
+ '</p></div></div>';
$.colorbox(
{
onLoad: function() {
$("#cboxClose").remove();
},
overlayClose: false,
href: dialog,
open: true,
title: "Program Approval",
inline: true,
height: "210px",
onClosed: function () {
$("[id$=btnHiddenApprove]").click();
}
});
e.stopPropagation();
} else {
th.attr('checked', false);
}
});

The problem on my page was a broken link. Just fixed that, so it shouldn't be a problem. That wasn't specific to IE8, and I haven't had any troubles with IE8.
The only problem I see with what you posted is that you have a stray quote mark in the opening <div> element. I checked your content in IE8 and that was indeed the issue:
This:
var dialog = '<div">'
Should be this:
var dialog = '<div>'
The stray quote mark makes your markup not well formed, and it's up to the browser how they want to respond or recover from the error, leaving for very inconsistent results.

Here is the revised code for who ever is interested .... this code will show a confirmation on a check-box, and uncheck it if cancel is selected. The onClosed event fires a hidden button click event that goes through the gridview and sets any checked check-boxes.
function UnCheckBox(cb) {
//alert(cb);
$('#' + cb + '').removeAttr('checked');
}
$(document).ready(function () {
$('input[name$=chkApproved]').click(function (e) {
var th = $(this);
if (th.is(':checked')) {
var dialog = '<div>'
+ '<div id="dialog">'
+ '<p style="margin-top: 30px;">'
+ 'Are you sure you want to approve this program?</p>'
+ '<p style="font-size: small;">'
+ '<strong>Note:</strong> This cannot be undone!</p>'
+ '<p style="text-align: center;">'
+ 'Approve'
+ ' '
+ 'Cancel'
+ '</p></div></div>';
$.colorbox(
{
onLoad: function() {
$("#cboxClose").remove();
},
href: dialog,
open: true,
title: "Program Approval",
inline: true,
height: "210px",
onClosed: function () {
$("[id$=btnHiddenApprove]").click();
}
});
e.stopPropagation();
} else {
th.attr('checked', false);
}
});

Related

Issue for the "change" event of "select" in ToolTipDialog execution times

Why Select change event execution times will increase with the number of button's click.
HTML :
<button id="btn">click me</button>
JS
require(["dojo/_base/declare", "dojo/dom", "dojo/on", "dojo/_base/lang", "dijit/registry", "dijit/TooltipDialog", "dijit/popup","dijit/form/Select", "dojo/_base/array", "dojo/domReady!"],
function(declare, dom, on, lang, registry, TooltipDialog, popup,Select, Array) {
var InfoWindow= declare( // 类名省略
TooltipDialog,
{
constructor: function (parameters) {
console.log("hello");
},
test:function(){
var tNode=dom.byId("btn");
var myTooltipDialog = new TooltipDialog({
id: 'myTooltipDialog',
style: "width: 300px;",
content: '<div id="tpDialog006" class="pDlg"></div><div id="selectMenu" class="right"><select name="select1" id="sel006" data-dojo-type="dijit/form/Select"> <option value="037" selected="selected">1</option><option class="left" value="005" >2</option><option class="left" value="007" >3</option><option value="006">4</option></select></div>',
onMouseLeave: function(e){
if(registry.getEnclosingWidget(e.target).name=="select1")
return;
popup.close(myTooltipDialog);
},
onOpen:lang.hitch(this, function(e) {
})
});
var sHu = registry.byId("sel006" );
sHu.on("change", function (e) {
alert( "value is" +sHu.value);
});
on(tNode,"click",function(){
popup.open({
popup: myTooltipDialog,
around: dom.byId('btn')
});
})
this.m1="t1";
}
}
);
var infoWindow = new InfoWindow({
});
infoWindow.test();
});
The code is at the link:code link
there may be some problem for the tooltipdialog shows but it will not affect the issue to be reproduced.
This is normal that the click is reproduced because :
in the button click (above) :
on(tNode,"click",function(){
popup.open({
popup: myTooltipDialog,
around: dom.byId('btn')
});
})
In every button click you are opening the Popup so, the tooltip's open function is being executed ( onOpen event fired ) which means that the change event is attached again to your sel006 select input .
What I propose to you is not to assign the select change event inside the tooltips onOpen event and just declare it after the toolTip initialization
So the code became :
var myTooltipDialog = new TooltipDialog({
id: 'myTooltipDialog',
style: "width: 300px;",
content: '<div id="tpDialog006" class="pDlg"></div><div id="selectMenu" class="right"><select name="select1" id="sel006" data-dojo-type="dijit/form/Select"> <option value="037" selected="selected">1</option><option class="left" value="005" >2</option><option class="left" value="007" >3</option><option value="006">4</option></select></div>',
onMouseLeave: function(e){
if(registry.getEnclosingWidget(e.target).name=="select1")
return;
popup.close(myTooltipDialog);
},
onOpen:lang.hitch(this, function(e) {
// remove event from here
})
});
var sHu = registry.byId("sel006" );
sHu.on("change", function (e) {
alert( "value is" +sHu.value);
});
Bellow a fiddle example : Fiddle

JQGrid - header and column not align

Hope someone could point me to right direction..
I'm facing this problem for quite sometimes.!
http://imgur.com/j8S9ft5
I try some of the solutions which I found from stackoverflow
e.g.jqGrid column not aligned with column headers
& other sources but none solved my problem. This problem only arise after upgrading to Chrome 19 and above (I think!) and safari 6. I noticed theres no problem when viewed in my 2nd computer which is using safari 5 and when I reinstall Chrome ver 18.
I try updating some of the js and css file by downloading from trirand.net but come to no solution.
Currently I'm running Safari Version 6.0.1 (8536.26.14) and Chrome Version 26.0.1410.43.
thanks
UPDATE 2: after updating to 4.4.5 image http://imgur.com/NlY786x
& I forgot to mention this only happen when I integrate inside lightbox(facebox)
UPDATE 3:
#Oleg I just realise after after updating to 4.4.5 or just paste ur code (inside comment)
I'm not able to use my custom button anymore (working b4).. nothing happen.
I'm using a javascript & a php jqgrid, below is my code:
<div align="center" id="grido"> </div>
<script type="text/javascript">
//var lastSel;
$(document).ready(function(){
// $('#grido').load('form/housekeeping/dun_grid.php');
});
</script>
<script type="text/javascript">
<!-- dun_grid.js -->
jQuery(document).ready(function(){
var lastSel;
jQuery("#dun_grid").jqGrid({
url:'form/housekeeping/dun_griddata.php',
datatype: "json",
colNames:['DUN ID','DUN Code', 'DUN Name'],
colModel:[
{name:'int_dunid',index:'int_dunid', hidden:true, align:"center", width:50},
{name:'txt_dcode',index:'txt_dcode', editable:true, align:"center", width:150},
{name:'txt_dname',index:'txt_dname', editable:true, align:"center", width:150},
],
pager: '#pagerdun', //pagination enable
rowNum:15,
rowList:[10,20,30],
width:430,
height:'auto',
sortname: 'txt_dcode',
sortorder: 'asc',
hidegrid: false, //show/hide grid button on caption header
viewrecords: true, //display the number of total records
editurl:"form/housekeeping/dun.php?mode=edit",
loadtext: "Loading Data, Please Wait...",
rownumbers:true, // add row numbers on left side
caption: ' DUN List',
ondblClickRow: function(id){
if(id && id!==lastSel){
jQuery('#dun_grid').restoreRow(lastSel);
lastSel=id;
}
jQuery('#dun_grid').editRow(id, true, "", refreshing);
},
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery('#dun_grid').restoreRow(lastSel);
lastSel=id;
}
},
}); /* end of jqgrid */
jQuery("#dun_grid").jqGrid('navGrid','#pagerdun',{edit:false, add:false, view:false, del:true, search:true},
{}, // edit
{}, // add
{url: 'form/housekeeping/dun.php?mode=delete'}, // delete
{multipleSearch : true},
{closeOnEscape:true}
); //end on navgrid
jQuery("#dun_grid").jqGrid('navButtonAdd','#pagerdun',{caption:"", buttonicon :'ui-icon-plus',
onClickButton:function(id){
jQuery('#dun_grid').restoreRow(lastSel);
var datarow = {txt_dname:""};
jQuery("#dun_grid").addRowData("0",datarow,"first");
jQuery('#dun_grid').editRow("0", true, "", tiesto);
lastSel=id;
},//end of onClickButton
title:"New Record",
position:"last"
}); //end of custom button
function refreshing(id){ /* refresh grid */
jQuery('#dun_grid').trigger("reloadGrid");
$.blockUI({ message:"Saving Data!!"});
setTimeout($.unblockUI, 700);
}
function tiesto(){
jQuery('#dun_grid').restoreRow(lastSel);
jQuery('#dun_grid').trigger("reloadGrid");
$.blockUI({ message:"New Data Saved!!"});
setTimeout($.unblockUI, 700);
}
}); /*end of document ready*/
</script>
<div align="center" class="gridpanel" >
<!--------------------------- ## grid for add/edit ## ------------------------------------------>
<table id="dun_grid" class="scroll" cellpadding="0" cellspacing="0"></table>
<!-- pager definition -->
<div id="pagerdun" class="scroll" style="text-align:center;"></div>
</div> <!----------------------- grid panel end -------------------------------------->
PHP
<?php
ini_set("display_errors","1");
require_once('../../Connections/jq-config.php');
// include the jqGrid Class
require_once "../../phpgrid/php/jqGrid.php";
// include the driver class
require_once "../../phpgrid/php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
$grid->SelectCommand = 'SELECT int_bankid, txt_bank_code , txt_bank_name, txt_bank_address FROM tbl_bank';
// set the ouput format to json
$grid->dataType = 'json';
$grid->table ="tbl_bank";
$grid->setPrimaryKeyId("int_bankid");
$grid->setColModel();
$grid->setUrl('form/housekeeping/bank_grid.php');
$grid->setGridOptions(array("editurl"=>"form/housekeeping/bank.php?mode=edit"));
// Set grid option
$grid->setGridOptions(array(
"caption"=>" List of Banks",
"rownumbers"=>true,
"rowNum"=>10,
"rowList"=>array(10,20,50),
"sortname"=>"txt_bank_code",
"hoverrows"=>true,
"hidegrid"=>false,
"height"=>'auto',
"width"=>460,
"sortorder"=>'desc',
"loadtext" => "meloading data...",
"cmTemplate"=>array("searchoptions"=>array("sopt"=>array('eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc')))
));
// Change some property of the field(s)
$grid->setColProperty("int_bankid", array("label"=>"ID", "width"=>50, "align"=>"center", "hidden"=>true));
$grid->setColProperty("txt_bank_code", array("label"=>"Code", "width"=>60, "align"=>"center", "editrules"=>array("required"=>true)));
$grid->setColProperty("txt_bank_name", array("label"=>"Name", "width"=>130, "align"=>"center", "editrules"=>array("required"=>true)));
$grid->setColProperty("txt_bank_address", array("label"=>"Address", "width"=>200, "align"=>"center"));
// enable navbutton
$grid->navigator = true;
$grid->setNavOptions('navigator', array("pdf"=>false,"excel"=>false,"add"=>false,"edit"=>false,"del"=>true,"view"=>false ));
$grid->setNavOptions('del',array("url"=>"form/housekeeping/bank.php?mode=delete"));
// jscript for adding new row
$reloading = <<<RELOAD
function(id)
{
jQuery("#grid").trigger('reloadGrid');
}
RELOAD;
$mycode = <<<NEWBUTTON
function(id)
{
jQuery("#grid").jqGrid('restoreRow',lastSel);
jQuery("#grid").jqGrid('addRowData',"0",{txt_bank_code:''},"first");
jQuery("#grid").jqGrid('editRow', "0", true,'',$reloading);
lastSel=id;
}
NEWBUTTON;
//jscript for inline editing
$editrow = <<<DOUBLECLICK
function(rowid)
{
if (rowid && rowid !== lastSel) {
jQuery("#grid").jqGrid('restoreRow', lastSel);
lastSel = rowid;
}
jQuery("#grid").jqGrid('editRow', rowid, true,'',$reloading);
}
DOUBLECLICK;
//custom button setting for adding new row
$buttonoptions = array("#pager", array("caption"=>"", 'buttonicon' =>'ui-icon-circle-plus', "onClickButton"=> "js:".$mycode));
// inserting custom button
$grid->setGridEvent('ondblClickRow', $editrow);
$grid->callGridMethod("#grid", "navButtonAdd", $buttonoptions);
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>
I had this same problem and was able to fix it by adjusting the CSS. I had set padding on the th which caused the issue.
It's possible that your th is inheriting padding which is messing up the alignment.
If the padding on the th is different than the grid cells (especially padding-left and right) it will break the alignment.
Try setting the property shrinkToFit as true;
shrinkToFit : true,
As given in the wiki
This option, if set, defines how the the width of the columns of the grid should be re-calculated, taking into consideration the width of the grid. If this value is true, and the width of the columns is also set, then every column is scaled in proportion to its width. For example, if we define two columns with widths 80 and 120 pixels, but want the grid to have a width of 300 pixels, then the columns will stretch to fit the entire grid, and the extra width assigned to them will depend on the width of the columns themselves and the extra width available.
Add this code into the gridComplete event of your grid. Don't forget to replace the gridName with your grid id:
var objHeader = $("table[aria-labelledby=gbox_" + gridName+ "] tr[role=rowheader] th");
for (var i = 0; i < objHeader.length; i++) {
var col = $("table[id=" + gridName+ "] td[aria-describedby=" + objHeader[i].id + "]");
var width= col.outerWidth();
$(objHeader[i]).css("width", width);
}
Works with v.4.6.0.
My Case
jqgrid version 4.6.0
Group Headers in the grid
shrinkTofit did not work
I called the following function in gridComplete event
function alignColumnsWithHeadersGENEL(gridName) {
var objHeaders = $("table[aria-labelledby=gbox_" + gridName + "] tr[class=jqg-first-row-header] th");
var objColumns = $("table[id=" + gridName + "] tr[class=jqgfirstrow] td");
for (var i = 0; i < objHeaders.length; i++) {
objHeaders[i].style.width = objColumns[i].style.width;
}
}
The structure of the HTML produced for my grid was something like the following(deleting the unnecessary fillings)
Somehow there were disrepancies between widths of the headers and columns

Add checkbox to the ckeditor toolbar to addClass/removeClass in img elements

I want to write a ckeditor plugin that adds a checkbox to the toolbar.
When an img element is selected, the checkbox should reflect whether the image has a certain class or not.
When something else than an image is selected, the checkbox should be
disabled, or maybe invisible.
When I check or uncheck the checkbox, the class should be added/removed to/from the img.
In other words, I want to add something else than a button to the toolbar (those that are added with editor.ui.addButton), and that something should be a checkbox.
How do I do that?
I managed to do it anyway, using editor.ui.add and editor.ui.addHandler. Here is a screenshot:
plugin.js:
CKEDITOR.plugins.add('add_zoomable_to_image',
{
init: function( editor )
{
var disabled_span_color = "#cccccc";
var enabled_span_color = "#000000";
var cb;
var span;
var html =
"<div style='height: 25px; display: inline-block'>" +
"<div style='margin: 5px'><input class='add_zoomable_cb' type='checkbox' disabled='disabled'>" +
"<span class='add_zoomable_span' style='color: " + disabled_span_color + "'> Add zoomable to image</span>" +
"</div>" +
"</div>";
editor.ui.add('add_zoomable_to_image', "zoomable_button", {});
editor.ui.addHandler("zoomable_button",
{
create: function ()
{
return {
render: function (editor, output)
{
output.push(html);
return {};
}
};
}
});
editor.on("selectionChange", function()
{
var sel = editor.getSelection();
var ranges = sel.getRanges();
if (ranges.length == 1)
{
var el = sel.getStartElement();
if (el.is('img'))
{
enable_input();
if (el.hasClass('zoomable'))
check_cb();
else
uncheck_cb();
}
else
disable_input();
}
else
disable_input();
});
editor.on("instanceReady", function ()
{
cb = $('.add_zoomable_cb');
span = $('.add_zoomable_span');
cb.change(function()
{
var element = editor.getSelection().getStartElement();
if (cb.is(':checked'))
element.addClass('zoomable');
else
element.removeClass('zoomable');
});
});
function enable_input()
{
cb.removeAttr('disabled');
span.css('color', enabled_span_color);
}
function disable_input()
{
uncheck_cb();
cb.attr('disabled', 'disabled');
span.css('color', disabled_span_color);
}
function check_cb()
{
cb.attr('checked', 'checked');
}
function uncheck_cb()
{
cb.removeAttr('checked');
}
}
});
CKEditor doesn't include the option to add a checkbox to the toolbar, so your first step is to look at their code and extend it to add the checkbox.
Then look at how other buttons work to modify the content and detect when the selection in the editor changes to reflect its new state, and apply those ideas to your checkbox.

Passing "href" as data in jQuery UI tabs() through Ajax

I have some tabs (jQuery UI tabs) in the "index.php" of a page. This page not only shows content, but also retrieves the $_GET variable to show some other content below the tabs.
The problem is how to tell jQuery UI that the href (attr of the clicked ) is a value for the key "href" that has to send (GET) to the current index.php page, called in JS has window.location.pathname (I can't use PHP generated JavaScript).
The code is this, and i'm out of options for how to make things work.
jQuery('#front-tab').tabs({
spinner: "Loading...",
select: '#tab-one',
cache: true,
fx: { height: 'toggle', opacity: 'toggle' },
url: window.location.pathname,
ajaxOptions: {
type: 'get',
success: function(){alert('Sucess');},
error: function(){alert('I HAZ FAIL');};
},
dataType: 'html'
}
});
The HTML:
<div id="front-tab">
<ul>
<li><span>Home</span></li>
<li><span>Tab Content 1</span></li>
<li><span>Tab Content 2</span></li>
<li><span>Tab Content 3</span></li>
<li><span>Tab Content 4</span></li>
</ul>
<div id="tab-home">
content...
</div>
</div>
Yep, this gets me full of "I HAZ FAIL" every time I try to load other tabs. The first tab is inline HTML, but the rest is Ajax. url: window.location.pathname doesn't seems to work or point to the right direction. Well, I don't know if that does what I am looking for.
function initTabs(elementHref) {
jQuery('#front-tab').tabs({
spinner: "Loading...",
select: '#tab-one',
cache: true,
fx: { height: 'toggle', opacity: 'toggle' },
url: elementHref,
ajaxOptions: {
type: 'get',
success: function(){alert('Sucess');},
error: function(){alert('I HAZ FAIL');};
},
dataType: 'html'
}
});
}
jQuery('yourLink').on('click', function() {
initTabs(jQuery(this).attr('href'));
});
Well, after noting the inflexibility of jQuery UI Tabs I had to replicate the action on my own. Better yet, few lines of code compared to two plugins.
front_tab.click(function(e) {
// Content parent
tab_content = $('#tab-content');
// other variables
var tab_visible = tab_content.children('div.visible'),
span = $(this).children('span'),
span_value = span.html(),
value = $(this).attr('href'),
// This gets our target div (if exists)
target = tab_content.children(value);
// There is no anchor
e.preventDefault();
// Don't do nothing if we are animating or "ajaxing"
if (tab_content.children().is(':animated') || is_ajaxing) { return; };
// Put the "selected" style to the clicked tab
if (!$(this).hasClass('selected')) {
front_tab.removeClass('selected');
$(this).addClass('selected');
}
// If is target div, call it
if (target.length > 0) {
is_ajaxing = true;
span.html('Loading...');
tab_content.children().removeAttr('class');
tab_visible.slideUp('slow', 'swing', function(){
// Some timeout to slow down the animation
setTimeout(function() {
target.attr('class', 'visible').slideDown('slow');
if (value = '#tpopular') { update_postbox(); }
is_ajaxing = false;
span.html(span_value)
}, 400);
});
// So, the target div doesn't exists. We have to call it.
} else {
is_ajaxing = true;
span.html('Cargando...');
$.get(
window.location.pathname,
{ href : value },
function(data) {
tab_visible.slideUp('slow', 'swing', function(){
setTimeout(function() {
tab_content.children().removeAttr('class');
tab_content
.append(unescape(data))
.children(value)
.css('display', 'none')
.attr('class', 'visible')
.slideDown('slow');
if (value = '#tpopular') { update_postbox(); }
is_ajaxing = false;
span.html(span_value)
}, 800);
});
},
'html');
}
});
The next problem is to make a nice error warning, but that is the solution.

text-decoration problem in Firefox, jQuery and jqgrid

I have issue wuth Firefox not displaying style "text-decoration: line-through".
I am using jqGrid for displaying list of medications. If medication is not active, it has to be crossed. In my afterInsertRow event I do this:
$('#' + rowid).css({ 'text-decoration': 'line-through', 'color': 'red' })
It works fine for IE and Chrome, but Firefox displays only red text without crossing line.
When I look into firebug output, I can see that <tr> element has style definition including text-decoration, but it is simply not displaying the way I need.
If you modify your code to
$('#' + ids[1] + " > td").css(
{ 'text-decoration': 'line-through', 'color': 'red' });
if will works. If you use rownumbers: true and don't want the row number be strikethrough, you can use
$('#' + ids[1] + " > td:not(.jqgrid-rownum)").css(
{ 'text-decoration': 'line-through', 'color': 'red' });
One more small recommendation: use gridview: true to fill jqGrid more quickly. In this mode the whole table contain will be filled by jqGrid as a siring and will be inserted with one jQurey.append operation. The usage of afterInsertRow event break the rule, because every row will be inserted with a jQurey.append operation and then will be called afterInsertRow. So my recommendation: use gridview: true and don't use afterInsertRow. To make changes of css use loadComplete or gridComplete instead like:
jQuery('#list').jqGrid({
//...
loadComplete: function() {
var ids = jQuery('#list').getDataIDs();
for (var i = 0; i < ids.length; i++) {
$('#' + ids[i] + ' > td:not(.jqgrid-rownum)').css(
{ 'text-decoration': 'line-through', 'color': 'red' });
}
}
// ...
});

Resources