When i click browser back button then nav bar menus was not active.
I solved it as below code inside onRendered function.
Tracker.autorun(function() {
var Rname = Router.current().route.getName();
if(Rname == 'xxx'){
$('.lib').addClass('active');
$('.default').removeClass('active');
$('.OnBack').removeClass('active');
}
if(Rname == 'yyy'){
$('.lib').removeClass('active');
$('.default').addClass('active');
$('OnBack').removeClass('active');
}
if(Rname == 'zzz'){
$('.lib').removeClass('active');
$('.default').removeClass('active');
$('.OnBack').addClass('active');
}
});
But when i copy URL and open in new tab then Rname gives correct value but active class not add.
How can i solve it.
Please Rply soon....
I want that if condition code execute using another function, because i have many conditions. How can be solve it in meteor???
I think you can use zimme:active-route. It does exactly what you need. Just read the documentation.
Related
lets say I have something like this:
'click #url_image': function(e) {
var className = $(this).attr("class");
console.log(className);
}
"this" in meteor is the context of the current template, not the actual item which was clicked. how could I get the class or other attribute from the actual click event, in this case the class of #url_image?
Thanks
Try
$(e.currentTarget).attr("class");
Or if you want a no-jQuery solution:
e.currentTarget.getAttribute('class');
I have a modal popup that appears whenever an editor tries to save a component with some values (a date field in the past in this case).
In this popup I show the editor a few options (very similar to the default "Open Shared Item" dialog) and an OK/Cancel button combo. On Cancel I fire the "cancel" event and the editor goes back to the editing screen, all good here. On "OK" I want to change the value of the field to match whatever the editor selected, then save.
I tried to use an approach with FieldBuilder and the sample Boris mentioned on this other topic but I can't get to the field from my popup dialog.
Any suggestions on how I can go and modify the xml of the item (could be also a page) from a modal popup?
EDIT: Code used in getControlForFieldName
function getControlForFieldName(name) {
var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
var fieldsContainer = fieldBuilder.properties.input;
var fieldsNode = fieldsContainer.getElement();
var fieldContainer = $dom.getFirstElementChild(fieldsNode);
while (fieldContainer) {
var labelNode = $dom.getFirstElementChild(fieldContainer);
var fieldNode = $dom.getNextElementSibling(labelNode);
var control = fieldNode.control;
if (control.getFieldName() == name) {
return control;
}
fieldContainer = $dom.getNextElementSibling(fieldContainer);
}
}
EDIT #2
After Frank's advice, and some help from Jaime & Frank offline, I got it to work as follows:
The popup is called from a Command Extension (Save & Close in my case)
The command.js specifies an event handler that gets called on "submit" (== OK was pressed)
$evt.addEventHandler(p.dialogPopup, "submit",
this.getDelegate(this._onPopupSubmit));
In my popup I am passing the selected item (it's a keyword ID) to the event handler:
this.fireEvent("submit", { id: select.options[select.selectedIndex].value });
and now back in the event handler _onPopupSubmit(e) I just read e.data.id, load this keyword, get properties like ID & Title, and update the metadata of the item using item.setMetadata("new metadata with updated values").
Simple :)
Your code runs in a popup, so any references you make to global variables will be taken from the popup window.
So when you get the fieldBuilder:
var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
$display is a reference to a global variable. So this actually looks for the FieldBuilder in the popup window (which doesn't have one).
To get the FieldBuilder of the Component window, you can get it from the opener:
var fieldBuilder = opener.$display.getView().properties.controls.fieldBuilder;
You might want to consider actually passing the updated value to either a callback function or with a (custom) event though, since that makes your popup less dependent on opener. trick.
I am trying to get a report based on different information located in tabs. How do I know If a tab is selected? I looked for something like:
if(colorListTab.isSelected)
{
}
but no luck! Can you guys help me out with this?
You could use the ActiveTab property, for example(in ActiveTabChanged):
if(TabContainer1.ActiveTab.Equals(colorListTab)){
}
or you could use the ActiveTabIndex:
if(TabContainer1.ActiveTabIndex == 1){ //second tab
}
http://www.dotnetcurry.com/ShowArticle.aspx?ID=178
Try using ActiveTabChanged event
Also please have a look at this question AJAX ToolKit TabContainer: Can I capture the “Active Tab Panel Changing” event
The property you're looking for is "ActiveTab", a property of the actual TabContainer (not an individual tab)
if(colorListTabContainer.ActiveTab.TabIndex == 1)
{
//You only get here if the index of the active tab is 1
}
I have a label in abc.aspx, say 'label1'. I want to assign a value to 'label1' from another page xyz.ashx. How can i do this?
In general, this doesn't make sense.
When your second page is executing, the first page is gone. It simply no longer exists. There is no label for you to assign to.
Even if you could assign to the label, the previous request is over. The HTML (without the change) has already been sent to the user's browser.
I think u pls try this
call getValuein document.ready
getValue = function() {
$.post('../ax/a.ashx?val=1'
,
{
spc: data // pass some data
}
, function(data) {
document.getElementById("<%=textBox1.ClientID %>").value = data;
});
}
I have sort of a table with a radio-button column. I managed to make radio-button column work dynamically inserting into a cell (div if matter). But, on postback innerHtml hasn't been updated with "checked" attribute.
Could you give me an idea how can I find out (on the server) if radio-button has been checked?
More info: This is on user control inside update panel.
This would be good post on my topic, still doesn't help
Any reason you cannot use a standard asp:RadioButton and use javascript to ensure it is mutually exclusive. I have done this before by adding a custom attribute to the radiobutton and then using a js function to uncheck all items with that attribute and then check the selected one. This works around the IE issue which prevents the groupname attribute from working on radioboxes that are in different containers.
radioButton.InputAttributes.Add("ClientGroupName", "grpRadioList");
radioButton.InputAttributes.Add("onclick",
string.Format(
"javascript:radiobuttonToggle('{0}','ClientGroupName','grpRadioList');"
,radioButton.ClientID));
and use the following JS to uncheck all radios and then check the one you want.
Note i used InputAttributes instead of Attributes as the radiobutton is wrapped inside a span tag so InputAttributes is for items added to the actual input control rather than the span.
function radiobuttonToggle(selectedRB, attribName, attribValue)
{
var objRadio = document.getElementById(selectedRB);
for(i = 0; i < document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i];
if (elm.type == 'radio')
{
if(elm.getAttribute(attribName) == attribValue)
elm.checked = false;
}
}
objRadio.checked = true;
}
You can then expose radioButton.Checked as a property in your CS file and reuse this as a control.
Check Form.Request("radio-name") != null
You only get a non-null value when it's been checked.
Make sure your page elements are being rebuilt correctly on postback. Any binding process that inserted the radio buttons the first time around will have to be re-run before you can access them the second time.
Here is a working example, first I add radios to my webform by the method you linked :
function addRadio()
{
try{
rdo = document.createElement('<input type="radio" name="fldID" />');
}catch(err){
rdo = document.createElement('input');
}
rdo.setAttribute('type','radio');
rdo.setAttribute('name','fldID');
document.getElementById('container').appendChild(rdo);
}
Then at code behind I used only the code below to get the radio's value :
string value = Request["fldID"];
So, be sure you're trying to get the name of the radio buttons at server side. You should use name attribute at server side, not id.