Is there a method to disable the insert image btn in summernote?
Related
Trying to find a good way to disable this save/submit button after it has been clicked once. Here is the code i currently have :
<button data-bind="enable: !$root.isSaving(), click: $root.addNewCard.bind($data, $root)" class="primary button" role="button" data-size="sm" onclick="this.disabled = true;" UseSubmitBehavior="false">Save</button>
The previous method i had above worked out well!
I am using scenebuilder to make the UI. I want to make the color of the buttons change when mouse is pressed or when the button is touched. Can I set the same method for both mouse pressed and screen touched events and also set the same events for multiple buttons? Like there are 3 buttons and I want to change their color in mouse pressed and screen touched events and use only one method for all.
Thank you
Lets say, you have three buttons
Button button1 = new Button();
Button button2 = new Button();
Button button3 = new Button();
Create a method saying
private void handleButtonAction(ActionEvent event) {
// Button was clicked, change color
((Button)event.getTarget).setStyle("-fx-background-color:PINK");
}
All buttons have a setOnAction() which is fired on both mouse pressed and screen touched events.
JavaDoc says
The button's action, which is invoked whenever the button is fired.
This may be due to the user clicking on the button with the mouse, or
by a touch event, or by a key press, or if the developer
programmatically invokes the fire() method.
Use it :
button1.setOnAction(this::handleButtonAction);
button2.setOnAction(this::handleButtonAction);
button3.setOnAction(this::handleButtonAction);
If you are using FXML
You can define one action for all buttons :
<Button id="button1" onAction="#handleButtonAction"/>
<Button id="button2" onAction="#handleButtonAction"/>
<Button id="button3" onAction="#handleButtonAction"/>
Inside the controller :
#FXML
private void handleButtonAction(ActionEvent event) {
// Button was clicked, change color
((Button)event.getTarget).setStyle("-fx-background-color:PINK");
}
I currently have a button that when pushed, opens up a text box. I want to do it so that the focus is automatically on this text box when the button is pushed.
I have the following HTML to render the button and input, and toggle between the button/input
{{#if modeIs 'edit' }}
<input class="col-xs-9" placeholder="Enter your new task and press enter" id="insertTask" type="text"/>
{{else}}
<button id="btnNewTask" class="btn btn-success btn-lg" role="button">New Task</button>
{{/if}}
Helper function to check the mode.
Template.insertNewTask.helpers({
modeIs: function (modeToCheck) {
return Session.equals('mode', modeToCheck);
}
});
This is the code I would like to use when the button is clicked to change the mode and focus on the input.
'click #btnNewTask': function (event, template) {
Session.set('mode', 'edit');
var input = $(template.find('#insertTask'));
if(input){
input.focus();
}
},
The bit to change the 'mode' works and the button changes to a text box when I click on it.
My problem is this query $(template.find('#insertTask')); returns nothing because although I've set the mode, it hasn't re-rendered the HTML yet and the text box doesn't actually exist yet.
Is there a way that when I set the mode to 'edit', to tell Meteor to just immediately re-render the HTML before proceeding with the rest of the function? Is there a better way to structure my code so that I can reference HTML components that don't exist until after Meteor re-renders the HTML?
Use the rendered hook:
Template.insertNewTask.rendered = function() {
var $input = $("#insertTask");
if (Session.equals('mode', 'edit')) $input.focus()
}
You could set another flag somewhere to indicate when you want to focus the input (eg. if you don't always want to focus it after rendering the edit view, just after clicking the button).
How can the cursor be focus on a specific input box on page load?
The button is "Add new appointment" the script is:
<input type="button" onclick="open_win()" value="add new appointment"/>
WebElement ek = driver.findElement(By.xpath("//input[#value='add new appointment']"));
jse.executeScript("arguments[0].click();", ek);
This opens a pop up window. Now I need to focus on the window.
Ajax is used to retrieve information from this pop up.
I tried every aspect to focus on the new pop up. The input txt fields are hidden, The code that I've tried is:
jse.executeScript("window.focus();");
driver.switchTo().defaultContent();
driver.switchTo().activeElement().findElement(By.xpath("//*[#id='barge:bargeId:txtInput']"));
driver.switchTo().alert();
I thought to focus on the text field with the following code:
jse.executeScript("document.getElementById('barge:bargeId:txtInput')[0].setAttribute('type', 'text');");
driver.findElement(By.xpath("//*[#id='barge:bargeId:txtInput']")).sendKeys("suxs");
This also haven't worked.
Even jse.executeScript("document.title") has not worked.
the code for text field
<span id="barge:bargeId:input">
<input id="barge:bargeId:txtInput" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all inputbox doubleInputbox ui-state-hover" type="text" tabindex="" maxlength="17" accesskey="" name="barge:bargeId:txtInput" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"/>
</span>
to click on the button you can simple do this: driver.findElement(By.xpath("//input[#value='add new appointment']")).click();
By saying "This opens a pop up window" do you mean an actual new window, new tab or dialog like this or like this?
I think it opens up the dialog, and in this case usually it's just another element on the page. And in this case this should work:
driver.findElement(By.xpath("//*[#id='barge:bargeId:txtInput']")).sendKeys("suxs");
UPDATE:
Since it's a new window, there ways to switch to the new window described here:
driver.switchTo().window("windowName");
Also, it would be helpful to check the code of open_win() javascript function.
I have a bootstrap page that lists items in a table. Each item has its own delete link that launches the modal.
<a href="#modalDel" data-idtodelete="<?php echo $value->id; ?>" class="deletelink">
Delete this item
</a>
...
jQuery("a.deletelink").click(function(event){
var id2del = $(this).data('idtodelete');
jQuery("#myModalLabel").html("Delete item: "+id2del); //works great
jQuery('#modalDel').modal('show');
});
I can pass data to the modal easily, but now I have to make the main button in modal to reflect the dynamic url and call to it (only) when this button is clicked
Any ideas? Thanks
PS: cannot use the hidden event for this, because modal can also be hidden with the cancel button. Also, modal should be closed after/before calling the dyn. delete url of main button
I'll hazard a guess at this. Haven't tested because I'm not really sure about the setup.
var $ = jQuery; // using as a shortcut
$('#modalDel').on('show',
function() {
// Composes delete URL with arguments
var dynUrl = composeUrl(args);
// assuming the modal button is an anchor element
$('#modalButton').attr('href', dynUrl);
// Also closes the modal box after being clicked
$('#modalButton').on('click',
function(e) {
$('#modalDel').modal('hide');
});
});