2016-07-28 15 views
0

私は編集画面から保存ボタンで食料雑貨のcrudのカスタムリダイレクトを使用しようとしています。私は正常に以下の例のようにURLフラグメントを使用してリダイレクトすることができます。Grocery Crud url redirection via javascript

$the_catalogue_id = $this->uri->segment(count($this->uri->segments));  
$this->grocery_crud->set_lang_string('update_success_message', 
      'Your data has been successfully stored into the database.<br/>Please wait while you are redirecting to the list page. 
      <script type="text/javascript"> 
       window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'"; 
      </script> 
      <div style="display:none">' 
     ); 

私は今、リダイレクトURLの末尾にwindow.location.hashを追加する必要があるが、それは仕事を得るように見えることはできません。これは今まで私が持っているものです:

$this->grocery_crud->set_lang_string('update_success_message', 
     'Your data has been successfully stored into the database.<br/>Please wait while you are redirecting to the list page. 
     <script type="text/javascript"> 
     var thehash = window.location.hash 
      window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'"#"+thehash"; 
     </script> 
     <div style="display:none">' 
    ); 

リダイレクトURLの最後にハッシュ変数を追加するにはどうすればよいですか?

答えて

0

"+thehash"から二重引用符を削除します。

連結演算子と変数は、生成されたjavascriptでは二重引用符で囲まないでください。

var thehash = window.location.hash; 
    window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'#"+thehash;