Jquery Datatable Hide delete button - jquery-plugins

I am using
$('#AffiliatedContractorLookup').dataTable().makeEditable
I want to give user the ability to add a new record , so for that purpose I used,
<div class="add_delete_toolbar" />
But this toolbar displays both Add and delete button. I want to hide the delete button. How can I acieve that ?

I know this is an old topic, but I had the same problem. I tried some solutions and here's one that worked for me:
in the file databled-editable you have this line:
if (oDeleteRowButton == null && properties.sDeleteRowButtonId != "") {
oAddDeleteToolbar.append("<button id='" + properties.sDeleteRowButtonId + "' class='delete_row'>Delete</button>");
oDeleteRowButton = $("#" + properties.sDeleteRowButtonId);
oDeleteRowButton.click(_fnOnRowDelete);
}
place it in comment, and the button won't be added

Even easier:
#btnDeleteRow
{
display:none;
}

To have only the "Add" button simply replace
<div class="add_delete_toolbar" />
with
<button id="btnAddNewRow">Add</button>

Related

how to check if form submitted in laravel?

I am trying to check if the form submit button is clicked so I tried:
if($request->input('submit')){
//do something
}
and tried:
$clicked=$request->input('submit');
if(isset($clicked)){
//do something
}
and also tried:
if($request->input('submit')!=null){
//do something
}
but when I do click the submit button in the form the execution of if-inside never happens so what is the right way to check if submit button clicked in laravel?
Check if the value of submit button is set. This might be the easiest also, I always use it.
HTML:
<button type="submit" name="find" value="Find">Find</button>
LARAVEL:
if (isset($request->find))
{
//code
}
this can be solved two ways:
first way if your form contains just one button and your form is using POST then like Adnan Mumtaz said we can use :
if($request->method() == 'POST'){
//ur code here
}
but if the form contains multiple buttons and we want check if button than have name btn1 clicked then we can use:
if($request->has('btn1')){
//rest of the code here
}
here is what I am using :
if($request->has('submit')){
//do something
}
If you are submitting the using POST method then you can check whether it is submitted via POST
if($request->method() == 'POST'){
//ur code here
}
You can use get() methid of request
if($request->get('submit')){
//do something
}
Make sure in view you have given button name submit
For example if your submit button html is like below
<input type="submit" name="submit_btn" value="add">
if($request->submit_btn == 'submit')
{
//code
}
Here it compare that if the submit_btn value is submit it means if submit ckicked.
Hope this can help.

Magento - Updating attribute IF THE OPTION changed

I really need some support regarding magento:
on this page: https://goo.gl/wTeUtG
If the option changed out of the dropdown, like from 150 Gramm to 200 Gramm, the ingredients (on this page as "Zutaten") also should be updated. But only the price is going to change not the text right into tooltip on "Zutaten".
How or where can I do this?
That's what I have tried so far:
I've created a new attribute and put it into the checkbox.phtml. This is the code for it:
<p>
<label>Zutaten:</label>
<a class="tooltips" href="#">
<img src="https://shop.ellyseidl.de/skin/frontend/base/default/pektsekye/optionbundle‌​/info_icon.gif" width="11px" height="11px" />
<span><strong>Zutaten:</strong>
<?php echo Mage::getModel('catalog/product')->load($_selection->getId())->getData('zutaten'‌​); ?>
</span>
</a>
</p>
But it doesn't change the tooltip once a option is selected
I guess you will have to do it manually with jQuery since you are using it on your page, by adding event on change on the select box with the id="attribute154" or the class="super-attribute-select".
You will have to change the text in the tooltip according to the option being selected.
EDIT:
jQuery('#attribute154').on('change', function() {
var selectedVal = jQuery(this).val();
//If you want to change the tooltip according to the selected text this is how you can get it:
var selectedText = jQuery(this).find("option:selected").text();
if (selectedVal != '') {
var ingredientsText = '';
if (selectedText == '150 Gramm') {
ingredientsText = 'Ingredients for 150 Gramm';
} else if (selectedText == '200 Gramm') {
ingredientsText = 'Ingredients for 200 Gramm';
}
//And so on
jQuery('.tooltips').find('span:first').html('Zutaten:'+' Folgen in Kürze: '+ingredientsText);
} else {
jQuery('.tooltips').find('span:first').html('Zutaten:'+' Folgen in Kürze: ');
}
});
Please have in mind that you must change the text the way you need it. I still don't know what you have to add in the tooltip, but I just tested this on your site and it works. According to the text Folgen in Kürze which means coming soon, not sure what is the text you need to update.
EDIT2:
The ingredientsText var will depend on the quantity of Gramm selected, if they are static you can enter them in the code by yourself, if they are dynamic, you will have to add them somewhere in the HTML in a hidden <div> for example and then fetch them with JS from there.

Change Ajax from onclick to onsubmit

I would like to change the following code, at the moment the code reads data from the input box of an ajax table (seven script - ajax table editor) then when you click save it adds it to the table. I would like it so it does this when the user presses enter, how can I do this by modifying the code:
if(editTblRow==null && editTblCell==null){
if(fieldtype!='blob'){
$($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<input type="text" id="edit_box" class=\"edit_input\" value=\"' + id + '\" /><div class=\"cell_opts\">Save - Cancel</div>');
} else {
$($('#ajaxtb')[0].rows[rowid].cells[cellid]).html('<textarea id="edit_box" class=\"edit_input\" value=\"' + id + '\" >' + id + '</textarea> <div class=\"cell_opts\">Save - Cancel</div>');
}
Try using this JQuery function. It will help identify if the enter key is clicked.
$(document).keypress(function(e) {
if(e.which == 13) {
// Your code here
}
});

View ckeditor content as html in new window

How to view ckeditor content as html in new modal window when a button is clicked which is placed beside the editor.
below is the html
<img src="Image/icons/preview.png" alt="Preview" id="img1" class="preview" />
<textarea rows="30" cols="22" id="txtHtmlHead" class="editor"></textarea>
The above textarea behaves as a ckeditor .
Please help me..
You can use window.open() with a tricky url to do that (fiddle):
CKEDITOR.replace( 'editor', {
plugins: 'sourcearea,wysiwygarea,toolbar,basicstyles',
height: 100
} );
// Executen on button click.
function show() {
var url = 'javascript:void( function(){' +
'document.open();' +
// Note that you may need to escape HTML entities here:
'document.write( "' + CKEDITOR.instances.editor.getData() + '" );' +
'document.close();' +
'})()';
window.open( url );
}
Such feature is also provided by the official Preview plugin so you might find it interesting.

How to perform click event on an element present in the anchor tag?

<div class="buttonClear_bottomRight">
<div class="buttonBlueOnWhite">
<a onclick="$find('{0}').close(true); callPostBackFromAlert();" href="#">Ok</a><div
class='rightImg'>
</div>
</div>
</div>
In the above code i wanted to click on Ok button present in the anchor tag.But an id is not generated because of which i cannot directly perform a click action. I tried a work around mentioned below.
IElementContainer elm_container = (IElementContainer)pw.Element(Find.ByClass(classname));
foreach (Element element in elm_container.Elements)
{
if (element.TagName.ToString().ToUpper() == "A")
{
element.Click();
}
}
But here elm_container returns null for intial instances due to which we cannot traverse through it. Is there any other easy method to do it ?
Try this...
Div div = browser.Div(Find.ByClass("buttonClear_bottomRight")).Div(Find.ByClass("buttonBlueOnWhite"));
Debug.Assert(div.Exists);
Link link = div.Link(lnk => lnk.GetAttributeValue("onclick").ToLower().Contains(".close(true)"));
Debug.Assert(link.Exists);
link.Click();
Hope it helps!
You can simply Click on the link by finding its text
var OkButton = Browser.Link(Find.ByText("Ok"));
if(!OkButton.Exists)
{
\\Log error here
}
OkButton.Click();
Browser.WaitForCompplete();
Or you can find the div containing the link like,
var ContainerDiv = Browser.Div(Find.ByClass("buttonBlueOnWhite"));
if(!ContainerDiv.Exists)
{
\\Log error here
}
ContainerDiv.Links.First().Click();
Browser.WaitForComplete();

Resources