In a JS file I would write
navPush(page, {paramOne: "something"})
In html, in order to write a push, I'd write
[navPush]="modelPage"
How do I add params to the above, in html?
You can pass parameters using the navParams property along with your navPush.
It's use is mentioned in ionic official docs. you can use it in your html as:
<button ion-button [navPush]="pushPage" [navParams]="params">Go</button> // params is the object which you intend to pass to the page;
To dynamically bind a single value you can use this code
<button ion-button [navPush]="NextPage" [navParams]="{color:[color]}">GO</button> // where color is a string variable
On NextPage use this code
this.color = navParams.get('color');
console.log(this.color[0]);
Related
I have to inject a Codesnippet on a specific place in a html.
For example:
<section class="newsletter">
content content content
</section>
Now I want the Tagmanager to inject on this section another code instead of the section newsletter.
<div class="injector">
content content content
</div>
Ive tried some scripts but none of them showed the content. The custom html has been loaded, but did not replace the section.
How should i do this?
Thank u!
you can use a custom script to append the content in an HTML tag
for example and with the provided data, using Jquery.
The only thing that you have to care about is that the function is executed, in this case i'm using a anonymous function
<script>
(function(){
var div = document.createElement('div');
var h1 = document.createElement('h1');
h1 = $(h1).text('tille');
div = $(div).text('content content content')
div = $(div).attr('class','injection')
div = $(div).append(h1)
$('.post-text').append(div)
}
)()
</script>
I made it this way:
<script>
jQuery('div#container_to_hang_on').append('<div id="injector"></div>');
</script>
But you #Kemen Paulos Plaza said its not recommended at all. Why? Is there a better way?
I was wondering how I could pass a link into to {{t}} helper. I am using v3.0.1 of Ember i18n at the moment.
Obviously you cannot pass a link helper into a t helper (something like
{{ t "some-translation-string" link={{#link-to 'page' model}}page{{/link-to}} }}
won't work of course).
So I was thinking, maybe I can create a custom prop that returns a whole link. But then again, how do I create that link?. Does anyone know of a method that has the same arguments as the link-to helper, but returns just the link (In my case 'page' and model)?
You might be able to achieve that with a basic link, but I doubt that you'll be able to toss a live link-to component inside a translation.
So instead split your translation string into pieces:
{{t 'goToSettingPage-before'}}
{{link-to (t 'goToSettingPage-link') 'route.name'}}
{{t 'goToSettingPage-after'}}
'goToSettingPage-before': 'Go to'
'goToSettingPage-link': 'settings'
'goToSettingPage-after': 'page.'
You can create a helper to do exactly what you want using ember-href-to.
Helper:
compute (params) {
const i18n = this.get('i18n');
const target = hrefTo(this, params[1]);
// const targetParam = params[2]; //dynamic segment
const text = i18n.t(params[0]);
return Ember.String.htmlSafe('<a href='+ target +'>' + text +'</a>');
}
Template usage:
{{t "linkExample-learnMore" link=(helper-name 'linkExample-here' 'some.route')}}
Translations:
"linkExample-learnMore": "Click {{{link}}} to do something",
"linkExample-here":"here"
By default, Limesurvey provides the follow text elements for the surveys - Survey title, Description, Welcome message, End message etc, which I can use in my template with tags like {SURVEYNAME}, {SURVEYDESCRIPTION}, {WELCOME} etc.
Is it possible to add my own custom field, which I can then use in the template? I need to do it this way because I need to have the text translatable, and present on every page.
You can not add a custom replacement with the current version of LimeSurvey. And your LimeSurvey version seems outdated. But LS includes jquery, therefore it's easy to move some element from a place to elsewhere.
Quick example:
<p>Here is your description</p>
<div style='display:none'>
<label for='languagechanger' id='labellang'>Here is the new label for language</label>
</div>
<script>
$(function() {
$("#labellang").insertAfter("#languagechanger")
});
</script>
A PHP solution, hacking LimeSurvey code, should be placed at https://github.com/LimeSurvey/LimeSurvey/blob/master/application/helpers/replacements_helper.php#L814
I have the following code in an Emblem.js template:
each segment in controller
.panel.panel-default
.panel-heading
h4.panel-title
a data-parent="#accordion" data-toggle="collapse" href="#collapse{{segment.id}}"
span {{segment.title}}
div id="collapse{{segment.id}}" class="panel-collapse collapse in"
What I'm actually trying to achieve is to interpolate object data into the HTML attributes. I been trying to {{segment.id}} but that render some script tags along with the value which is not what I'm looking for. Is there another way to do this?.
Until HTMLBars comes out, Ember.js is going to need to insert placeholder tags to manipulate the DOM. You have two options:
Create a computed property that will join the strings for you, then use bind-attr to apply the property to the ID or class.
Use the unbound helper. This will do what you want, but it won't update the property if it changes.
I suggest doing the first if you can.
if the data isn't going to change, you can use unbound and it'll just jam it in there without script tags.
each segment in controller
.panel.panel-default
.panel-heading
h4.panel-title
a data-parent="#accordion" data-toggle="collapse" href="#collapse{{unbound segment.id}}"
span {{segment.title}}
div id="collapse{{segment.id}}" class="panel-collapse collapse in"
I studied the Crispy-Forms documentation and I tried to put an extra button into one of my forms. With
self.helper.add_input(Button('back', "Back", css_class='btn'))
I can add a nice button. But the Button() wont take an onclick or on_click-attribute. So how can I add logic to this button? Adding an onclick event with JQuery isnt a very nice solution...
Thanks!
Ron
Are you certain that Button will not take onclick in its kwargs?
I just added an onclick="javascript here" to a Submit() element and it displayed fine.
I also peered a bit at the underlying code, and I think all inputs by default flatten the kwargs that aren't popped because of special use (i.e. template), and pass those through into the rendered HTML. This may be new since April '12 (when originally posted), but it currently seems to be as simple as the following:
self.helper.add_input(Button('back', "Back", css_class='btn', onclick="alert('Neat!');"))
This is not included by default (afaik..).
If you just need this once, is possible to use crispy-forms HTML Layout Object
HTML('<input type="button" name="Save" onclick="do_whatever" />')
What do you then dislike using jQuery? You could handle this rather easy and generic, using something like:
$('form :submit.ajax_submit').live('click', function(e) {
e.preventDefault();
var my_form = $(this).parents('form');
// do whatever
alert(my_form.attr('id'));
alert(my_form.attr('action'));
});
and then just pass the class:
Submit('save', 'save', css_class='ajax_submit')