I have a turbo frame with a src attribute, this works as expected when I load the page, but if I visit another page and click the back button it doesn't work. The src url is not been triggered.
= turbo_frame_tag "#{dom_id(object)}_active_tab" do
= turbo_frame_tag "documents", src: documents_path(object_id: object, format: :html)
Related
I am working with Next.js. Suddenly I realized that hot reload is not working. Instead, with any changes in the page elements, the page would be fully refreshed, not hot reload.
Let say that there is a file in pages folder called test.js. The content of test.js is as follows:
function test() {
return <div>Test <div>;
}
export default test;
the above code simply, output a simple test message in the page when visiting a local url like this: http://localhost:3000/test .
When I change the test text into something else such as test2, I expect that I should see the new change (test2) instantly in the page (hot reload), but unfortunately the page fully reloads first, and then I can see the new changes in the page (in this example, the new test2 text). This is bothers me so much to wait to see the changes by page refreshing, not by hot reload.
How I can tell Nex.js, not to fully reload the page with any change in page element, but instantly show them on the page, as it is expected ??
The console log message is as follows:
I want to create a button in a googlesheet/google Apps Script that opens an existing google sheet in a new tab when u click on it. I will insert the button in a google sheet, so i basically just need a code that i link to the button.
The code below does not work somehow?
Can you help me?
function openURL(){
var button = CardService.newTextButton()
.setText("This button opens a link in an overlay window")
.setOpenLink(CardService.newOpenLink()
.setUrl("google sheet")
.setOpenAs(CardService.OpenAs.OVERLAY)
.setOnClose(CardService.OnClose.RELOAD_ADD_ON));
};
In order to create such button and functionality, you will have to:
Create the code that will be executed upon clicking it. Go to Tools>Script Editor. Paste the following code (replacing, of course, the url for the appropriate one):
function openMySpreadsheet() {
var url = 'YOUR_SHEET_URL';
var htmlTemplate = HtmlService.createTemplateFromFile('js');
htmlTemplate.url = url;
SpreadsheetApp.getUi().showModalDialog(htmlTemplate.evaluate().setHeight(10).setWidth(100), 'Opening Sheet...');
}
Still from the Google Apps Script IDE, go to File>New>HTML File. Set the file name to be js and paste the following code into it:
<script>
window.open('<?=url?>', '_blank', 'width=800, height=600');
google.script.host.close();
</script>
Go back to your Sheets document and insert an image using Insert>Image>Image over cells and select any image you would like to have as your button.
Select the newly created image and click on the 3 dots that appear on the top-right corner of it. Click on "Assign script", and put the function name to be run (in this case, openMySpreadsheet would work).
From now on, each time you click on the button, a short-lived dialog will be shown up (that is necessary in order to open a link on a new tab) and the link will be automatically open.
During a functional test i need to click a button to make an ajax request.
When browsing the symfony testing docs, i realized that you could whether click :
a Link
or
a form's submit button
My button has the following id = "js-scroll-down"
When i try this:
$btn = $crawler->filter('#js-scroll-down')->eq(0)->link();
$crawler = $client->click($btn);
I get the following error:
LogicException: Unable to navigate from a "button" tag.
The Client#click() expects only Link.
But you can execute script, e.g. $client->executeScript("document.querySelector('#js-scroll-down').click()");
I'd like to be able to redirect to a given URL if it fails to load with Fancybox 3. The users supply the URL's so it could be a youtube video, image, or some other arbitrary link. In the case of something like a Google Doc, google prevents you from loading those inside iframes, so I'd like to catch that error and stop the fancy box viewer from loading at all and instead redirect to that URL directly in the browser. I can kind of get it working but I can't seem to stop the fancy box dialog from showing before the redirect happens:
$.fancybox.defaults.afterLoad = (instance, current) ->
if current.hasError
window.location = current.src
instance.close()
I've tried returning false.
This is the best I have come up with so far:
$.fancybox.defaults.defaultType = 'iframe'
$.fancybox.defaults.beforeLoad = (instance, current) ->
$.ajax
url: current.src
method: 'HEAD'
.catch ->
window.location = current.src
instance.close()
The default for a URL is ajax if it fails all the other tests (like image and video), so we need to switch this to iframe first. Then I do an ajax HEAD call to see if the result is successful, if not, we can just redirect to the src. instance.close() is the best way I could find to stop the fancybox from loading (it could already be loaded if this is a slideshow/gallery anyway). There is a brief flash before the page then redirects to the URL.
As #misorude mentions, there isn't a way to detect if the iframe failed to load for cross site requests. In the end I decided to do away with previewing off-site links completely and do a redirect like so:
$.fancybox.defaults.afterLoad = (instance, slide) ->
if !slide.redirecting && slide.contentType == 'html'
slide.redirecting = true
message = """<div class="fancybox-error"><p>Redirecting...</p></div>"""
instance.setContent slide, message
window.location = slide.src
This displays a nice redirecting message and then sends the user on to that link via the browser. contentType is only html when it's not image, video, map etc... from the other media type plugins. This means fancybox can still show youtube links without trouble even though these are iframe and html based.
I'm using the extjs library. I've got a blank panel and I want to load another one of my ext projects into it with an iframe. Here is my function (called from a button), "thepanel" is my blank panel.
function(button){
var div = document.getElementById('thepanel');
div.innerHTML = "<iframe src=\"../../../project2/?&type=grades&gradeitem1=40691&\"></iframe>";
}
I can see the GET request in firebug's console when I run the function and all my second project code/data all shows up in an iframe when I look a the HTML in firebug but nothing new shows up in the browser. Any ideas of what could be keeping my iframe's contents from showing
I am using MVC architecture, here is the code that declares my panel:
items:[{
xtype:'panel',
itemId:'two',
id:'thepanel',
region:'center',
}]
UPDATE: I've tried moving the iframe to the html config option of the panel instead of adding it through jquery with a button click. Again, I can see the code from the url in the iframe show up in firebug but nothing shows up in my application. Here is the code declaring my panel:
xtype:'panel',
itemId:'two',
id:'thepanel',
region:'center',
html:'<iframe src=\"../../../extjproh2/?&type=grades&gradeitem1=40691\"></iframe>',
height:400,
width:400,
Ended up using this plugin from the sencha forums:
http://www.sencha.com/forum/showthread.php?110311-iframePanel&p=943573#post943573