I am new in rails.I am wondering that how to use the click event in rails 4.1.
In menus_controller:
def index
#menus=Menu.where(:hotel_id=>#hotel.id).sorted
#cart = current_cart
if :MEAL
#menus=Menu.where(:hotel_id=>params[:hotel_id],:item_type=>'Meal').sorted
#cart = current_cart
end
in Menus/index:
<%=button_to("MEAL",{:controller=>'menus',:action=>'index',:hotel_id=>params[:hotel_id]}, class:'linkstyle ')%>
After using the above code the page gets redirected to Menus#create,why this happened?
In index page i have this button and i want to stay in the same page after clicked this button which will call the if block in the index method in controller.
Related
I created a dynamic menu in oracle apex but the issue when click on any page after login
to the application again it redirect to login page first then open the page
this is the URL appear when click any page in the navigation menu
http://localhost:8080/ords/r/apex-system/login?session=11974340821162
this is the SQL query for dynamic menu :
select level ,
EN label,
'f?p=&APP_ID.:'||menu_seq||':'||':&SESSION.:::::' target,
EN as is_current,
ICON_IMAGE image_value
from SYSTEM_MENU
start with parent_m_id is null
connect by prior menu_id = parent_m_id
order siblings by menu_id
why always go to login page when click any page link on the navigation menu ?
Sounds like the session is getting reset when navigating to a menu item. At first glance (untested) I'd say there is a syntax error in the url. The session substitution string is in the wrong place. Try replacing ':&SESSION.:::::' with '&SESSION.:::::'.
But... why bother constructing the application url yourself when you can have a function APEX_PAGE.GET_URL do it for you ?
select level ,
EN label,
APEX_PAGE.GET_URL (p_page => 'menu_seq') target,
EN as is_current,
ICON_IMAGE image_value
from SYSTEM_MENU
start with parent_m_id is null
connect by prior menu_id = parent_m_id
order siblings by menu_id
I have page 1 from which I open a modal dialog page - page 2. Now when I close the modal dialog, I want to be redirected to page 3. On page 2 I have a button that has a dynamic action defined where on button click two actions take pace: Page Submit (with an after submit branch out to page 3) and Close dialog. Once I click on the button, dialog closes but the user stays on page 1, not going to page 3.
If you have branch, you don't need to close dialog..
Another option is to travel through pages using PL/SQL-JS combination that redirects to URL after running code on server.
create a hidden, unprotected item called P2_TARGET
create a button with action defined by dynamic action,
add a dynamic action onClick for that button, with two true actions:
a. Execute PL/SQL code, submit P2_Item, return P2_TARGET
declare
js_code varchar(4000);
begin
js_code := REGEXP_REPLACE(
APEX_PAGE.GET_URL (
p_page => 3,
p_clear_cache => 3,
p_items => 'P3_Item',
p_values => :P2_Item
)
,'\,this\)'
,q'<,$('#p1Region'))>' -- jQuery of event source
);
apex_util.set_session_state('P2_TARGET', js_code);
end;
b. Execute Javascript code:
eval($v('P2_TARGET'));
and that's supposed to do the trick
I've got a popup message with a close button at the top. If the user clicks the close button, they should never see the message again while on the site. If they don't click the close button, they will see it on the top of each page on the site.
When the user clicks the close button, I want to set request.session['promo'] to 0. On subsequent page loads on the site, if request.session['promo'] == 0, I will not show the popup message.
What is the best way of setting a session variable on click in django?
Thanks for the direction!
In HTML OnClick of button just call a function in views.py
Ex:
IN HTML :<Button onclick={% your_fucntion %}></button>
IN VIEWS.PY :
def your_fucntion(request):
request.session['promo'] == 'your_variable'
for getting variable :
promo = request.session['promo']
I have Custom page "All Posts"
Can i integrate batch action into this custom page for assigning the post to a particular category
ActiveAdmin.register_page "All Posts" do
menu :priority => 1#, label: proc{ I18n.t("active_admin.dashboard") }
content do #title: proc{ I18n.t("active_admin.dashboard") }
#how can i put here a batch action
end
end
how can i put here a batch action as it gives errors when i write the batch action for resource code.
should i write the page_action and then customize it using javascript and partials.
Thanks in advance
You can try to add batch_action by
batch_action :export do |selection|
keys = Model.find()
redirect_to admin_path_to_page_with_category_selection_path(post_ids: selection)
end
and selectable column
index download_links: [:xlsx] do
selectable_column
.....
end
admin_path_to_page_with_category_selection_path goes to view with category combobox, selected posts and submit button
I have a rails controller page home_controller.rb
class HomeController < ApplicationController
def index
##users = User.all
#loan_applications = LoanApplication.all
end
def button_listing_show
redirect_to lp_banker_assignments_path
end
end
And I have this Rails Slim button code
button Go to Listings onclick="<%home.button_listing_show%>"
What i want is on the onclick events the page redirects to this path.
Can someone provide an answer for me either in Slim or in Rails.
Thanks
button Go to Listings onclick="#{lp_banker_assignments_path}"
You are just generating a path with that function, so why not just interpolate to the path directly?
Docs for variable interpolation