Using Yii 1.1.14 on Apache 2.2 with PHP 5.3.10
The default entry point into a controller renders a layout with a sidebar that contains an autocomplete widget and a $content section. The autocomplete widget is a rip (see blog) and inside the run method the JQuery autocomplete is method chained to adjust how results are displayed.
There is an action on the controller that renders a view that has an iframe (with an href to another site). When that view is rendered the JavaScript registered by the autocomplete extension is gone. Traced the output of the render call and it is not present. However, the script is still registered.
Tried to override the afterRender method and when the view in question was rendered do something like:
Yii::app()->getClientScript()-render(&$output);
which does append the Javascript. Unfortunately, the Javascript is still missing.
Put a trace at the beginning and the end of the widget's run method. Seeing a trace when the normal entry point is rendered as well when the view with the iframe is rendered. So the widget is getting run correctly.
Could it be that the action that causes the view with the iframe isn't terminating correctly? Or do embedding iframe just blow out Javascript and there is no fix?
Related
In a Razor Pages view (no "#page" attribute; just a cshtml file), I'm attempting to render an anchor tag. I don't want to employ the tag helper, I just want it to render like this:
<i class="fas fa-fast-backward"></i>
The view renders with no error message, but the "href" and "onclick" attributes inside the anchor tag simply do not render. The "class" attribute does render. If I add other attributes to the tag they also render. I'm using fontawesome icons, and they render properly. But the "href" and "onclick" attributes do not render.
For the "href" attribute, if I change the value to "#", it renders. Obviously, something in the RazorPages rendering engine is saying "I will not render this" if the attribute contains javascript.
This apparently only happens in a view. I notice that I try to render the same element on a page (has the #page attribute) it renders fine.
The view itself is rendered when a user clicks a button, which makes a fetch call, which hits a server-side method that renders the view like this:
return Partial("_MyViewName", myModel);
Is there any way to render static values in the href and onclick attributes in an anchor tag in a Razor view?
I was inadvertently removing the javascript myself because, in javascript, I was passing the value returned from the server through the DOMPurify library (to guard against a javascript injection attack). This was very stupid of me, but special thank you to #KingKing for forcing me to figure it out.
I've created a simple blazor app that has a slider on top. There is a javascript self executing function that adds some inline css to this slider so it makes its' height the same as window.height.
I'm adding this javascript file in _Host.cshtml, before closing the body tag.
My issue is that this inline styling isn't applied. I've debugged the javascript code and it gets the correct height, the element on which I want to add the styling is found, the element.css('height', myHeight) is being called with the correct value, but in the end there is no style attribute on that element. I've also tried, after the component has been rendered, to remove the script tag from the page and add it again, hoping that it will re-run and then change the height, but no success there as well.
I've created a .NET Core WebApp using that same slider and everything works as expected (I have the style attribute on my element). In this second app I add the script before closing the body tag, in _Layout.cshtml.
Seems preety much the same as the blazor app, but for some reason, on that one doesn't work.
Do you guys have any idea why?
EDIT:
I've found something interesting. In the beginning, the page is loaded correctly, but the component is being reloaded after the app connects to the we socket Information: WebSocket connected to wss://localhost:44361/_blazor?id=cepYgPnJYddq2bHSywwwYw.. This is when I lose the inline styles.
So how can I stop it from reloading? I guess this is the question.
I am working with angular 2 rc4 and we are using fuel-ui http://fuelinteractive.github.io/fuel-ui/#/ to load a modal.
What we are trying to achieve is the following:
we have a login component that we want to inject into the fuel-ui modal the problem is that the actual modal html code (actual DOM) is getting loaded after.
Fuel-ui gives a tag into which the html for the modal gets loaded into.
I have researched and tried DynamicComponentLoader although found out it is now deprecated.
What I need is to know what is the best way to inject my login component content
into the rendered DOM (tag with modal-body class from bootstrap html).
I have searched but perhaps someone had the same issue and stumbled upon a better link that explains how to do this.
Thank you, in advance, for your help.
Nancy
This seems very old now. But i think the latest in Angular helps you use content projection into a component.
You can add <ng-content></ng-content> as the body of your modal. In the parent component view add your custom component wrapped in the modal component. When modal shows up, you will have your component in it's content.
Also, Angular supports dynamic component creation.
Component templates are not always fixed. An application may need to
load new components at runtime.
You can look it up here for any help:
dynamic-component-loader
I would have 10 bootstrap buttons on a single html page.
Each button opens a ootstrap modal filled with a html fragmen via an ajax request.
<div class="modal fade" id="myModal"></div>
$('#myModal').modal();
Should I create 10 different divs with 10 different ids? Or even 10 different instances?
var dialogInstance1 = new BootstrapDialog({
title: 'Dialog instance 1',
message: 'Hi Apple!'
});
or
should I create ONE dialog?
I would expect kind of caching problems when I open modal1, then just when I open modal2 I see still for some miliseconds modal1 html fragment from a prvious ajax request.
And how should I create those modals? The samples should this:
$('#myModal').modal();
and the instantiation? This is very confusing.
Can someone please share his experience how to approach with many bootstrap modals?
I would expect kind of caching problems when I open modal1, then just when I open modal2 I see still for some miliseconds modal1 html fragment from a prvious ajax request.
Assuming you're referring to data-remote's caching, you will probably be able to disable that in Bootstrap v3.2.0 (see https://github.com/twbs/bootstrap/pull/13183/ ).
However, I'd still recommend against using data-remote since it doesn't give you much control. It:
doesn't provide or easily let you do any error handling
doesn't give any "loading..." indication
forces you have to generate modal HTML on the server side (as opposed to, e.g., returning JSON from the server and using client-side templating)
IMO, you should:
include just one instance of the blank modal markup
setup your own click event handlers on the buttons that summon your modal
initiate the AJAX request in your click event handler
use client-side templating to generate a corresponding modal using the results of the request
use $(...).modal() or $(...).modal('show') (depends on how your templating works) to show the modal after the templating completes
I need to display content in a lightbox along with recaptcha.This was very easy except that recaptcha can be used only one per page.So, that threw the hidden div option away. Now, iam trying to render the content via js.erb using jquery's html() method. Rest of the content is rendered correctly.But, i'm having trouble rendering recaptcha.Is there a way to render recaptcha via jQuery html() method? I am using Ambethia reCaptcha.
Found a solution. I used a single Div(main lightbox container).Within that div, i added another div which wrapped <%=recaptcha_tags%>.This inner div was placed using absolute positioning.For the rest of the content, i used jquery's append() function instead of html() function.